我想將jsonarray反序列化爲對象列表。使用包裝類將JsonArray轉換爲模型
JSON字符串是在這裏:
[{
id: 1,
customer: "Joe Black",
items: {
id: 1,
description: "One",
unit_price: 1.00,
quantity: 1
}
},{
id: 2,
customer: "Joe",
items: {
id: 2,
description: "two",
unit_price: 1.00,
quantity: 4
}
}]
和
JsonConvert.DeserializeObject<List<rootClass>>(jsonString)
更新:這是我的班
public class customer {
public int id {get; set;}
public string customer {get; set;}
public Item item {get; set;}
}
public class Item {
public string id {get; set;}
public string description {get; set;}
public int unit_price {get; set;}
public int quantity {get; set;}
}
你使用什麼編程語言? – JJJ
@Juhana看來,作者使用C# – reporter
@Juhana我使用c# – user2011138