- Home /
How to write a json tree?
Hello,
I'm using SimpleJson as my parser and builder:
link text
I do I write my Json tree like this in script? It must look something like this:
{
"email": "user email will be here"
{
"username": "username will be here",
"password": "password will be here"
}
}
This is what I have so far:
JSONNode N = null;
N ["email"] = email;
N ["email"] ["username"] = username;
N ["email"] ["password"] = password;
// the "N" must be taken as one.
Answer by ghostmode · Oct 14, 2017 at 01:32 AM
The json object you're attempting to create is not valid json. This is what you're after:
{
"email": "email will be here",
"login":
{
"username": "username will be here",
"password": "password will be here"
}
}
You can generate this using SimpleJSON as follows:
var node = new JSONObject();
node["email"] = "some@email.com";
node["login"] = new JSONObject();
node["login"]["username"] = "AzureDiamond";
node["login"]["password"] = "hunter2";
Debug.Log(node);
Some things to consider:
Unity has JSON built in, there's no need to use SimpleJSON
You should absolutely not be storing login details in plain text like JSON
Hello and thank you for your response.
There should be a way to secure the json. Correct?
How do you intend on 'securing the json' exactly?
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Parsing multiple json files that are referencing each other 0 Answers