标签:超人 collect object span col style public fun 创建
using System.Collections; using System.Collections.Generic; using UnityEngine; using LitJson; public class ListJson : MonoBehaviour { void Start () { //fun1(); fun2(); } //private void fun1() //{ // 创建Json // { "Name":"超人","Power":90} // JsonData cJD = new JsonData(); // cJD.SetJsonType(JsonType.Object); // cJD["name"] = "超人"; // cJD["power"] = 90; // Debug.Log(cJD.ToJson()); // 打印 // { "name":"\u8D85\u4EBA","power":90} //} private void fun2() { JsonData herosJd = new JsonData(); JsonData herosJd1 = new JsonData(); herosJd1["name"] = "超人"; herosJd1["power"] = 90; JsonData herosJd2 = new JsonData(); herosJd2["name"] = "哮天犬"; herosJd2["power"] = 150; JsonData heros = new JsonData(); heros.SetJsonType(JsonType.Array); heros.Add(herosJd1); heros.Add(herosJd2); herosJd["heros"] = heros; Debug.Log(herosJd.ToJson()); //打印 //{ "heros":[{"name":"\u8D85\u4EBA","power":90},{"name":"\u54EE\u5929\u72AC","power":150}]} } }
标签:超人 collect object span col style public fun 创建
原文地址:https://www.cnblogs.com/yueqingli/p/10156591.html