我正在尝试从 http 帖子中读取 json 字符串,我正在尝试通过手动填充 json 字符串来测试我的代码,但我的问题是我无法多次添加相同的节点....换句话说,如果我输入以下内容,它会起作用:
Dim json As String = "{'name': 'jocelyne','mo': '70274724'}
但如果我输入以下内容,它就不起作用:
Dim json As String = "{'name': 'jocelyne','mo': '70274724'},{'name': 'eliane','mo': '12345678'}"
我实际上有数百个姓名和 mo 号码将在 json 字符串中发送给我
这是我的整个代码:
Request.InputStream.Position = 0 'you need this else the magic doesn't happen
Dim inputStream As New StreamReader(Request.InputStream)
'Dim json As String = inputStream.ReadToEnd()
Dim json As String = "{'name': 'jocelyne','mo': '70274724'},{'name': 'eliane','mo': '12345678'}"
Dim jss As New System.Web.Script.Serialization.JavaScriptSerializer()
Dim dict As Dictionary(Of String, String) = jss.Deserialize(Of Dictionary(Of String, String))(json)
For Each item As KeyValuePair(Of String, String) In dict
Response.Write(item.Key & " - " & item.Value & "<br>")
Next
那么我该如何解决呢?我只需要能够读取使用 http post 给我的这种 json 格式并反序列化它以读取数据