赞
踩
{ "JosnName":"按实际的号", "Size":25, "intArray":[10,20,30,40], "mData":[{ "index":0, "mJson":"ss0", "nNickName":{ "mFileName":"2222" } }, { "index":1, "mJson":"ss1", "nNickName":{ "mFileName":"1111" } }] }
类必须添加Serializable属性否则无法实现嵌套解析
[Serializable] public class Data { public string JosnName; public int Size; public int[] intArray; public DateInfo[] mData; } [Serializable] public class DateInfo { public int index; public string mJson; public NameClass nNickName; } [Serializable] public class NameClass { public string mFileName; }
直接调用Unity提供的接口JsonUtility.FromJson即可实现解析
Data tempDate = JsonUtility.FromJson<Data>(tempcontent);
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。