I have a JSON object that I store in a database that is created by var data = JSON.stringify($('#frm').serializeArray()); I want to call it and use Newtonsoft.json to parse it out into it's parts. My totally convoluted VB.Net code is (Dont pick on me I know it is a hack)
Dim reader As JsonTextReader = New JsonTextReader(New StringReader(TextBox1.Text))
Dim firstname As String = ""
Dim middleInitial As String = ""
Dim lastName As String = ""
While (reader.Read())
Select Case reader.Value
Case "disFirst"
reader.Read()
reader.Read()
firstname = reader.Value
Case "disMiddle"
reader.Read()
reader.Read()
middleInitial = reader.Value
Case "disLast"
reader.Read()
reader.Read()
lastName = reader.Value
End Select
End While
MessageBox.Show(firstname + " " + middleinitial + " " + lastName)
but it works. I 100% know that there are MUCH better ways so if someone can point me in the right VB.Net direction that would be great. My Json string is
[{"name":"disFirst","value":"Robert"},{"name":"disMiddle","value":"S"},{"name":"disLast","value":"Smith"},{"name":"disSuffix","value":""},{"name":"disEmail","value":"[email protected], [email protected]"},{"name":"disAffiliations","value":"Arizona\r\nXXXX"},{"name":"disPMIDlist","value":""},{"name":"disThreshholdFactor","value":""}]
JObject.Parse(jstr)). That seems like it should deserialize to an array pretty easily. Seems a bad structure though since the names arent related to each other. "Robert" is not linked or related to "Smith"