如何从C#中的以下JSON对象中提取ID?

时间:2016-12-02 05:51:33

标签: c#

我想使用c#从下面的对象中提取所有ID。 需要在visual studio webtest中提取响应值。 使用提取事件获取JSON。

 {
       "d": [
            {
              "__type": "QuestionZoneEditor.Entities.QuestionTag",
              "Id": 2080,
              "Name": "01",
              "Items": [
                "1a",
                "1b",
                "1c",
                "1d"
              ]
            },
            {
              "__type": "QuestionZoneEditor.Entities.QuestionTag",
              "Id": 2081,
              "Name": "02",
              "Items": [
                "2a(i)",
                "2a(ii)",
                "2b",
                "2c"
              ]
            },
            {
              "__type": "QuestionZoneEditor.Entities.QuestionTag",
              "Id": 2082,
              "Name": "03",
              "Items": [
                "3a",
                "3b",
                "3c"
              ]
            }
            }
          ]
        }

1 个答案:

答案 0 :(得分:3)

将其反序列化为var app = angular.module('todoApp', []); app.controller("dobController", ["$scope", "$http", function($scope, $http) { $http.get('test.json').then(function(response) { $scope.collection = response.data.Collections; console.log(response); }); $scope.display = function(name) { alert(name.split("::")[0] + "." + name.split("::")[1]); } } ]); ,然后从JObject获取所有JObject并打印JArray

Id

完整示例:dotNetFiddle