赞
踩
{
"name": "John",
"age": 30,
"married": true,
"address": {
"street": "123 Main St",
"city": "New York",
"state": "NY",
"postal_code": "10001"
},
"phone_numbers": [
"555-1234",
"555-5678"
],
"career": null,
"hobbies": ["reading", "traveling"]
}
Person person = JsonConvert.DeserializeObject<Person>(json);
string jsonStr = JsonConvert.SerializeObject(person);
Person person = JsonMapper.ToObject<Person>(str);
// 解析json字符串
JsonData jsonData = JsonMapper.ToObject(jsonStr);
// 根据json的对象名来获取数据
Debug.Log("name = " + (string)jsonData["name"]);
string jsonStr = JsonMapper.ToJson(persion);
Person person= JsonUtility.FromJson<Person>(json);
string jsonStr= JsonUtility.ToJson(person);
JSONNode node = JSON.Parse(str);
var Nmae = node["Nmae"].Value;
var age = node["age"].AsFloat;
JSONNode nodeRoot = new JSONObject();
JSONNode node1 = new JSONArray();
for (int i = 0; i < books.Count; i++)
{
JSONNode node0 = new JSONObject();
node0.Add("Name", books[i].name);
node1.Add(node0);
}
nodeRoot.Add("Preson", node1);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。