直接在 ArrayList 中检索 HttpWebRequest.GetReponse

Retrieving HttpWebRequest.GetReponse in an ArrayList directly

我有一个代码:

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", ...]"

但我需要在我的 ListBox 中有一个 ArrayList,如下所示:

string1
字符串 2
字符串 3
string4

好的,我可以使用 Split(",") 进行提取,但也许我可以立即恢复 ArrayList 中的数据吗?
"string1"、"string2"、"string3" ?

没有“[和]"n for a string and without "”

谢谢,
埃拉

你有一个 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

参考文献: