这是我的代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim JsonSub As String = "{""subdomain01"":[""21"",""subdomain01"",""4""],""subdomain02"":[""22"",""subdomain02"",""4""]}"
Dim objSub As JObject = JObject.Parse(JsonSub)
Dim dataSub As List(Of JToken) = objSub.Children().ToList
For Each subdomain As JProperty In dataSub
subdomain.CreateReader()
For Each pSub As JObject In subdomain.Value.ToString
MsgBox(pSub.ToString)
Next
Next
End Sub
如何在该字符串的数组中获取值:
["" 21"""" subdomain01"""" 4" "]
答案 0 :(得分:0)
如果你想做到这一点,做一个分裂:
Dim resultarray As String() = JsonSub.Split(":")(1).Split(",")
Dim result As String = resultarray(0) & "," & resultarray(1) & "," & resultarray(2)
作为JsonSub.Split(CChar(“:”))(1)将返回[“”21“”,“”subdomain01“”,“”4“”],“”subdomain02“”
反过来,用逗号分隔,将在你的“,”之间划出4个子串。您只需要取前3个,结果如图所示。