Private Sub decodeJSON(sData As String)
Dim p As Object
Set p = JSON.parse(sData)
If Not (p Is Nothing) Then
If JSON.GetParserErrors <> "" Then
MsgBox JSON.GetParserErrors, vbInformation, "JSON Error"
Else
'MsgBox = p.Count
MsgBox "OUT : " & JSON.toString(p)
MsgBox p.Item("name")
End If
Else
MsgBox "Parse Error"
End If
End Sub
... but I read only only first row...
HOW CA I LOOP? (i want to load all record in a recordset...)
Thank you...
If you want to read all 5 of your "Rows" properly, then you have to validate your JSON-string first:
Any decent parser will only go up to the point where the second curly-brace-opening starts:
{"0":"1","id":"1","1":"cliv","name":"cliv","2":"alecsandri","address":"alecsandri","3":"29-Jan-14 10:42:55 AM","datetime":"29-Jan-14 10:42:55 AM"}{...
You will need to introduce commas between the Curly-Braces, to separate the Object-entries - and you will have to enclose the whole
construct within square-brackets, to treat those 5-Objects as Array-members ... below is a correctly formatted version of what I mean.
(you can simply use an Online-JSON-validator for such things - e.g. this one here was quite good: http://jsonlint.com
Oh - and there's quite a bit of "unnecessary redundancy" in your data - hope you're aware of that.
Hi, sorry to bring the topics again, but I have the proper JSON format, So how can I loop through all the sets. Thank You in Advance.
I think I solve the issue. Thank you anyway :-)
If Not (p Is Nothing) Then
If JSON.GetParserErrors <> "" Then
MsgBox JSON.GetParserErrors, vbInformation, "JSON Error"
Else
Dim I As Long
' MsgBox p.Count
' MsgBox "OUT : " & JSON.toString(p)
' MsgBox p.Item("name")
I = 0
For I = 1 To p.Count
MsgBox p.Item(I).Item("id") & " - " & p.Item(I).Item("name")
Next
End If
Else
MsgBox "Parse Error"
End If