簡體   English   中英

如何在 c# 3.5 框架中從 JSON 中獲取所有值?

[英]How to get all values from JSON in c# 3.5 framework?

下面是我的 JSON 響應。 我想獲取orderidcaseid每個都一一提交及其價值。

"cases": [
  {
    "status": "DISMISSED",
    "createdAt": "2015-09-18T08:56:04+0000",
    "investigationId": 19246020,
    "caseId": 19246020,
    "score": 794.6295793608853,
    "adjustedScore": 794.6295793608853,
    "updatedAt": "2015-09-18T08:56:05+0000",
    "headline": "Steven Rusk",
    "orderId": "116588",
    "orderDate": "",
    "orderAmount": 425.0,
    "associatedTeam": {
      "teamName": "B2C Jewels",
      "teamId": 4289
    },
    "reviewDisposition": null,
    "uuid": "5821ed91-5f8f-4b51-bd63-a8834f2a95b3"
  },
  {
    "status": "DISMISSED",
    "createdAt": "2015-09-16T11:33:28+0000",
    "investigationId": 19114061,
    "caseId": 19114061,
    "score": 241.65405995385285,
    "adjustedScore": 241.65405995385285,
    "updatedAt": "2015-09-18T19:07:51+0000",
    "headline": "221.134.83.50",
    "orderId": "101",
    "orderDate": "2015-09-16T17:07:30+0000",
    "orderAmount": 9.99,
    "associatedTeam": {
      "teamName": "B2C Jewels",
      "teamId": 4289
    },
    "reviewDisposition": null,
    "uuid": "301f2cfc-3b67-4fc0-bf83-19099c2ea4bf"
  },
]

您將必須創建一個名為 case 的類,然后您需要將您的 json 映射到列表,然后您可以遍歷列表,希望它對您有用。

 List<cases> = new JavaScriptSerializer().Deserialize<List<cases>>(your json string);

您可以從 Nuget 安裝 Json.Net 包,然后在您的項目中添加這行代碼

var myList = Newtonsoft.Json.JsonConvert.DeserializeObject("Your Json String..!!");

這應該這樣做

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM