我有一个代码:
Dim myReq As HttpWebRequest
Dim myResp As HttpWebResponse
myReq = HttpWebRequest.Create("http......")
myReq/Method = "GET"
myReq.ContentType = "application/json'
myResp = myReq.GetResponse
Dim myreader as New System.IO.StreamReader(myResp.GetResponseStream)
Dim myText As String = myreader.ReadToEnd
我有:
myText =" [" string1"," string2"," string3",...]"
,但是我需要在这样的列表中使用一个arraylist:
字符串1
字符串2
字符串3
String4
好吧,我可以用split(","(提取,但也许我可以立即在阵列列表中恢复数据吗?
对于字符串,没有" [and] n(,而没有" for" string1"," string2"," string3"?
谢谢,
ela
您拥有的是一个JSON数组。您可以使用newtonsoft.json nuget软件包来解析。
这是使用它的最小示例:
Imports Newtonsoft.Json.Linq
Module Module1
Sub Main()
Dim myText = "[""string1"", ""string2"", ""string3""]"
Dim p = JArray.Parse(myText).ToObject(Of String())
For Each q In p
Console.WriteLine(q)
Next
Console.ReadLine()
End Sub
End Module
参考:
使用jarray.parse
将json转换为类型