【问题标题】:JSON.net getting value in child while loopingJSON.net 在循环时获得子项的价值
【发布时间】:2016-03-18 01:28:45
【问题描述】:

嘿,我正在尝试获取 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"
    }
  ]
}

child 的值为:

{
  "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 中的值??

【问题讨论】:

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


    【解决方案1】:

    一个 Json 阅读器(比如来自 newtonsoft 的那个)应该可以解决你的问题

    看看这个

    How to read JSON http post response using VB

    【讨论】:

      猜你喜欢
      • 2021-09-25
      • 1970-01-01
      • 1970-01-01
      • 2020-01-12
      • 1970-01-01
      • 2015-09-16
      • 2021-09-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多