您应该按照POCO对象创建自己:
public class Service{ public int idservice { get; set; } public string title { get; set; } public string message { get; set; }}public class UserServices{ public int id_user { get; set; } public List<Service> services { get; set; }}
LitJSON将立即反序列化此序列:
UserServices services = JsonMapper.ToObject<UserServices>(rawJson);
作为替代方案,您可以使用非通用变量(下面的示例会将所有数据写入控制台):
JsonData data = JsonMapper.ToObject(rawJson);Console.WriteLine("User id: {0}", data["id_user"]);Console.WriteLine("Services:");for (int i = 0; i < data["services"].length; i++){ Console.WriteLine (" Id: {0}; Title: {1}; Message {2}", data["services"][i]["idservice"], data["services"][i]["title"], data["services"][i]["message"]);}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)