Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i'm trying to read a json string from an http post, i'm trying to test my code by filling the json string manually but my problem is that i'm not able to add the same node many times.... in other words if i put the following it works:

VB
Dim json As String = "{'name': 'jocelyne','mo': '70274724'} 


but if i put the following it does not work:
VB
Dim json As String = "{'name': 'jocelyne','mo': '70274724'},{'name': 'eliane','mo': '12345678'}"


and i actually have hundred of names and mo numbers that will be sent to me in a json string

this is my entire code:
VB
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

so how can i fix this? i just need to be able to read this json format given to me using http post and deserialize it to read the data
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900