【问题标题】:How to get all values from JSON in c# 3.5 framework?如何在 c# 3.5 框架中从 JSON 获取所有值?
【发布时间】:2015-09-29 10:55:05
【问题描述】:

以下是我的 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"
  },
]

【问题讨论】:

    标签: c# asp.net json


    【解决方案1】:

    您必须创建一个名为 case 的类,然后您需要将您的 json 映射到列表,然后您可以遍历列表,希望它对您有用。

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

    【讨论】:

      【解决方案2】:

      你可以从 Nuget 安装 Json.Net 包,然后在你的项目中添加这行代码

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

      应该这样做

      【讨论】:

        猜你喜欢
        • 2020-10-16
        • 2022-11-11
        • 2017-12-10
        • 2023-03-05
        • 1970-01-01
        • 1970-01-01
        • 2022-01-07
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多