找到的一个Unity C#的Json库 支持各个平台
https://github.com/facebook-csharp-sdk/simple-json/tree/master/src/SimpleJson
例子地址:
https://github.com/facebook-csharp-sdk/simple-json/wiki/Getting-Started
JsonArray tja=new JsonArray();
tja.Add("1");
tja.Add("2");
tja.Add("3");
JsonArray tja1=new JsonArray();
tja1.Add("11");
tja1.Add("22");
tja1.Add("33");
tja.Add(tja1);
string json1=tja.ToString();
Debug.Log("JsonArray------------");
Debug.Log("json:"+json1);
JsonArray desTja1=(JsonArray) SimpleJson.SimpleJson.DeserializeObject(json1);
Debug.Log("JsonArray Deserialize---------");
for(int i=0;i<desTja1.Count;i++)
{
Debug.Log(desTja1[i]);
if(i==desTja1.Count-1)
{
JsonArray desTja2=(JsonArray) SimpleJson.SimpleJson.DeserializeObject(desTja1[i].ToString());
for(int j=0;j<desTja2.Count;j++)
{
Debug.Log(desTja2[j]);
}
}
}
JsonObject tjo=new JsonObject();
tjo["key1"]="1";
tjo["key2"]="2";
JsonObject tjo1=new JsonObject();
tjo1["key3"]="33333";
tjo["key3"]=tjo1.ToString();
string json2=tjo.ToString();
Debug.Log("JsonObject------------");
Debug.Log("json:"+json2);
JsonObject desJo1=(JsonObject) SimpleJson.SimpleJson.DeserializeObject(json2);
Debug.Log("JsonObject Deserialize---------");
Debug.Log("tjo key1:"+desJo1["key1"]);
Debug.Log("tjo key2:"+desJo1["key2"]);
JsonObject desJo2=(JsonObject) SimpleJson.SimpleJson.DeserializeObject(desJo1["key3"].ToString());
Debug.Log("tjo key3:"+desJo1["key3"]);
Debug.Log("tjo1 key3:"+desJo2["key3"]);