【发布时间】:2018-10-11 13:45:41
【问题描述】:
我无法从“list”中获取“kode”作为该对象的数组。
{
"metaData":{
"code":"200",
"message":"Sukses"
},
"response":{
"list":[
{
"kode":"31486",
"nama":"Satro Jadhit, dr"
},
{
"kode":"31492",
"nama":"Satroni Lawa, dr"
}
]
}
}
我可以从 JSON 中获取除数组之外的任何内容。 我试过使用这个解决方案 [How to read JSON http post response using VB
还有其他解决方案,但我的 vb 没有 newtonsoft json 的某些功能。 我使用 Visual Studio 2005,.net 框架 2.0
那么,我如何将它作为我的数组。
编辑
这是我尝试过的,我可以从“列表”中获得价值 (我用的是别的代码,所以这个值不一样)
Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Dim kodeDpjp as string
Dim json As String = responseFromServer
Dim serObj As Newtonsoft.Json.Linq.JObject =
Newtonsoft.Json.Linq.JObject.Parse(json)
Dim token As Newtonsoft.Json.Linq.JToken = serObj.SelectToken("response")
("list")
If (token.GetType() Is GetType(Newtonsoft.Json.Linq.JArray)) Then
Console.WriteLine(token)
End If
这就是结果
[
{
"kode": "8784",
"nama": "drg.MELANI SARI TANJUNG"
},
{
"kode": "8848",
"nama": "drg.ARIEF KURNIAWAN"
},
{
"kode": "8873",
"nama": "drg.SRI ARIANI SUGIARTI"
}
]
我只想在组合框中为我的数组“kode”
谢谢
【问题讨论】:
-
我已尝试使用此解决方案... 在这种情况下,请edit 分享您尝试但无效的问题。原因请参阅How to Ask,它建议帮助他人重现问题。
-
@BrianRogers 我使用 json.net .net 2.0
-
@dbc 谢谢,我已经编辑了我的问题。
标签: arrays json vb.net json.net visual-studio-2005