JWT
Member
I'am trying to parse a JSON object, which is downloaded from a webservice, but I get a java runtime exception. I followed one of the various examples in this forum and I checked the JSON download in an online JSON validator, which states it is a valid JSON object.
Here is the part of code I use.
This is the JSON object
I wonder why this is not functioning. If I remove the JSON array brackets [], then there's no error, but I only see only one row in the mapNew variable.
Here is the part of code I use.
JSON.NextObject:
Dim j As HttpJob
j.Initialize("", Me)
j.Download(PostURL)
' uitgezet j.PostString(PostURL, "")
' j.GetRequest.SetHeader("API-Key", pTikkieApiKey)
Wait For (j) JobDone (j As HttpJob)
PostStatus = j.Response.StatusCode
If j.Success Then
PostResponse = j.GetString
If PostStatus = 200 Or PostStatus = 201 Then
strResult = "OK"
Dim rowData As List
rowData.Initialize
Dim mapNew As Map
mapNew.Initialize
Dim JSON As JSONParser
JSON.Initialize(PostResponse)
mapNew = JSON.NextObject
mSize = mapNew.Size
For Each k As String In mapNew.Keys
Dim row(8) As Object ' 8 columns in sql select
rowItems = mapNew.Get(k)
' other parts of working code'
tblVNewRows.Items.Add(row)
Next
Else
strResult= "NOK"
NoOfNewRows = -1
End If
Else
strResult= "No Succes"
NoOfNewRows = -2
End If
j.Release
Return strResult
End Sub
JSCON data:
[{"row0": {"id":"25","datetime":"20200328140500","worker":"adworker","repeat":"-","counter":"0","system":"PW","action":"nodeid=bll&set=off","args":"*"}},{"row1": {"id":"26","datetime":"20200328141500","worker":"adworker","repeat":"-","counter":"0","system":"PW","action":"nodeid=sll&set=off","args":"*"}},{"row2": {"id":"27","datetime":"20200328141500","worker":"adworker","repeat":"-","counter":"0","system":"PW","action":"nodeid=sll&set=off","args":"*"}},{"row3": {"id":"28","datetime":"20200328141500","worker":"adworker","repeat":"-","counter":"0","system":"PW","action":"nodeid=sll&set=off","args":"*"}},{"row4": {"id":"29","datetime":"20210324153418","worker":"adworker","repeat":"-","counter":"0","system":"RF","action":"run Go","args":"test args"}}]
I wonder why this is not functioning. If I remove the JSON array brackets [], then there's no error, but I only see only one row in the mapNew variable.