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
'중국인턴(Intern In China) > 업무(Tasks)' 카테고리의 다른 글
Unity HTTP (www) get, put, post (0) | 2017.01.10 |
---|---|
Parsing data from Json (0) | 2017.01.10 |
Loaded Json Data from Server@@@ (0) | 2017.01.06 |
First Assignment in China (0) | 2017.01.05 |
Read Json file in Unity3D (0) | 2017.01.05 |