Unity read Json data
Reading Json data using dlll had dictionary error, and I studied using JsonUtility
Through script, class should be identified Serializable like below:
[Serializable] //using System must be added
class Data
{
public string name;
public List<string> likes;
public int level;
}
and create a variable type of 'Data', then use JsonUtility.ToJson method to convert 'Data' type to Json like below
var data = new Data();
data.name = "Park";
data.level = 10;
data.likes = new List<string>() {
"dog", "cat"
};
/*
{
"name": "Park",
"likes": [
"dog",
"cat"
],
"level": 10
}
*/
Debug.Log(JsonUtility.ToJson(data, prettyPrint: true));
Annotation in /* */ would be printed in console like below
Thanks to: http://pjc0247.tistory.com/32