Hello guys!
I have a question regarding the json format and how to convert from object to json string.
[Serializable]
protected class JsonWrapper
{
public string name;
public string surname;
public string occupation;
public List<List<string>> requests = new();
}
I have a JsonWrapper object as follows which contains nested list as a member
I need to convert this guys into json string that looks like this
{
"name": "some_name",
"surname": "some_surname",
"occupation": "dentist",
"requests": [
["money", "500"],
["help", "psychological"]
]
}
The code that I use to do that is as follows:
JsonWrappet toJson = new JsonWrapper();
toJson.name = "some_name";
toJson.surname = "some_surname";
toJson.occupation = "dentist";
toJson.requests = new();
// Creating a list
List<string> firstReq = new();
firstReq.Add("money");
firstReq.Add("500");
// Convert to Json
string s = UnityEngine.JsonUtility.ToJson(toJson);
print(s);
The output of this is as follows:
{"name":"some_name","surname":"some_surname","occupation":"dentist"}
I don't see anything from requests
Can anyone give me a hand regarding this issue?