VB.net在字符串数组中获取项目值



这是我的代码:

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

如何在字符串数组中获取value:

["21","subdomain01"、"4"]

如果你想要的只是这个,做一个分割:

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个,结果如下所示:

相关内容

  • 没有找到相关文章

最新更新