JsonData data = JsonMapper.ToObject(File.ReadAllText(@"C:\project\package\Assets\Item.txt"));
//List<Skill> skillTxt = new List<Skill>();
foreach (JsonData temp in data)//这里temp表示一个对象
{
JsonData idValue = temp["id"];
print(idValue);
}
我这样子写的解析他抛出异常是这个求解决
InvalidOperationException: Instance of JsonData is not a dictionary
LitJson.JsonData.EnsureDictionary ()
LitJson.JsonData.System.Collections.Specialized.IOrderedDictionary.GetEnumerator ()
LitJson.JsonData.System.Collections.IDictionary.GetEnumerator ()
inventoryManager.ParseItemJson () (at Assets/Scripts/inventoryManager.cs:43)
inventoryManager.Start () (at Assets/Scripts/inventoryManager.cs:55)