使用数组反序列化json对象

时间:2016-07-28 12:31:47

标签: c# json

我有一个json对象,它有一个我喜欢反序列化的json数组

{
  "status": 1,
  "loans": [
    {
      "loan_id": "686",
      "client_id": "269",
      "client_name": "Byaruhanga Guard",
      "total_amount": "10000",
      "min_amount": "10000",
      "start_date": "2016-07-28 13:12:30",
      "duration": "2",
      "payment_interval": "day",
      "voucher": "92",
      "description": "FUEL",
      "when_added": "2016-07-28 13:12:30",
      "approval_status": "approved",
      "total_paid": null,
      "next_payment_date": "2016-07-29 10:12:30"
    }
  ]
}

请帮忙。

1 个答案:

答案 0 :(得分:0)

使用NuGet包中的Newtonsoft.Json

var results= JsonConvert.DeserializeObject<string[]>(jsondata);

var loanjson=results["loans"];

var loandata= JsonConvert.DeserializeObject<string[]>(loanjson);