使用Json.net反序列化JSON对象数组
我试图使用一个API,使用以下示例结构为他们返回的json
[ { "customer":{ "first_name":"Test", "last_name":"Account", "email":"test1@example.com", "organization":"", "reference":null, "id":3545134, "created_at":"2013-08-06T15:51:15-04:00", "updated_at":"2013-08-06T15:51:15-04:00", "address":"", "address_2":"", "city":"", "state":"", "zip":"", "country":"", "phone":"" } }, { "customer":{ "first_name":"Test", "last_name":"Account2", "email":"test2@example.com", "organization":"", "reference":null, "id":3570462, "created_at":"2013-08-12T11:54:58-04:00", "updated_at":"2013-08-12T11:54:58-04:00", "address":"", "address_2":"", "city":"", "state":"", "zip":"", "country":"", "phone":"" } }]
JSON.net可以使用类似以下结构的东西
{ "customer": { ["field1" : "value", etc...], ["field1" : "value", etc...], }}
但我无法弄清楚如何让它对提供的结构感到满意。
使用默认的JsonConvert.DeserializeObject(content)会生成正确的Customer数,但所有数据都为null。
在CustomerList(下面)执行某些操作会导致“无法反序列化当前JSON数组”异常
public class CustomerList{ public List<Customer> customer { get; set; }}
思考?
慕村225694
慕姐4208626
收到一只叮咚