使用C#反序列化嵌套JSON而不使用类声明

时间:2016-09-19 14:13:51

标签: c# json json.net

我正在尝试动态deserialize一个对象,但不确定语法是什么:

JSON看起来像这样:

  "Id": 2750,
      "Rev": 1,
      "Fields": {
        "System.AreaPath": "test",
        "System.TeamProject": "proj",
        "System.IterationPath": "Ipath",
        "System.WorkItemType": "type"
}

我知道可以像这样访问它们:

var resultString = response.Content.ReadAsStringAsync().Result;
var jsonObject = JObject.Parse(resultString);
string ID= jsonObject["id"].ToString();

但我不确定如何直接获取嵌套在Fields中的值。 我知道我可以遍历jsonObject["Fields"],但我希望通过像jsonObject["Fields\\System.AreaPath"].ToString()之类的东西来访问它们。或者是正确的语法,如果它存在的话。

0 个答案:

没有答案