JSON.net在循环时获得了孩子的价值

时间:2015-12-12 01:48:57

标签: json vb.net json.net json-deserialization

嘿所有我想要获取 F_TableOtherFamily-> F_Table 中的值并循环以获取其中的内容的名称和值但是我似乎无法使用以下代码执行此操作:

For Each msg As JObject In json1("entry")
   Dim results As List(Of JToken) = msg("content")(formName).ToList()

   For Each pair As JProperty In results
      pair.CreateReader()

      If pair.Descendants.Count > 1 Then
         'has more values (like in a TABLE)
         For Each child In pair
            'not sure how to get other values
         Next
     Else
         'It only has one value
          Debug.Print(pair.Name)
          Debug.Print(pair.Value.ToString)
     End If
  Next
Next

msg的json值为:

{
  "content": {
    "@type": "application/xml",
    "F_Form1": {
      "@uid": "fb1ad4ec",
      "F_TableOtherFamily": {
        "F_Table": {
          "F_OtherFamilyName": "BLANK1",
          "F_OtherFamilyID": "BLANK2",
          "F_OtherFamilyRelation": "BLANK3"
        }
      },
      "F_ReceivedYorN": "Y",
      "F_ContractNumber": "901841586"     
    }
  },
  "link": [
    {
      "@href": "../../../../../secure/org/data/c76df8888ada/F_Form1/fb1ad4ec",
      "@rel": "edit"
    }
  ]
}

的值为:

{
  "F_Table": {
    "F_OtherFamilyName": "BLANK1",
    "F_OtherFamilyID": "BLANK2",
    "F_OtherFamilyRelation": "BLANK3"
  },
  "F_Table": {
    "F_OtherFamilyName": "BLANK1-1",
    "F_OtherFamilyID": "BLANK2-2",
    "F_OtherFamilyRelation": "BLANK3-3"
  }
}

我不知道如何循环获取 F_Table 中的值

1 个答案:

答案 0 :(得分:0)

Json读者(就像来自newtonsoft的读者)应该解决你的问题

看看这个

How to read JSON http post response using VB