iOS Question Strange Issue with JSONParser

RVP

Active Member
Licensed User
Longtime User
I have a json string, jstring

B4X:
[{
    "locationid": "shoot",
    "shootdate": "2017-04-02",
    "markerno": "0",
    "id": "2",
    "markerlong": "-122.993092350662",
    "uom": "Meter",
    "markerlat": "50.0925794844874"
}, {
    "tolight": "0",
    "id": "2",
    "color": "-14534267",
    "candles": "0",
    "shutter": "24",
    "locationid": "shoot",
    "markerno": "1",
    "fstop": "1.4",
    "candelas": "0",
    "asa": "25",
    "markerlong": "-122.992754392326",
    "height": "1",
    "distance": "45",
    "shootdate": "2017-04-02",
    "markerlat": "50.0922353295581"
}]

I am parsing like this:

B4X:
Dim json As JSONParser
    json.Initialize(jstring)
      
    list1 = json.NextArray

I would expect to have two items in the list, however I have 4, each item is repeated as below

B4X:
<B4IList: (
    "NSMapTable {\n[0] uom -> Meter\n[1] markerlong -> -122.993092350662\n[4] locationid -> shoot-3\n[5] markerlat -> 50.0925794844874\n[10] markerno -> 0\n[11] shootdate -> 2017-04-02\n[14] id -> 3\n}\n",
    "NSMapTable {\n[0] uom -> Meter\n[1] markerlong -> -122.993092350662\n[4] locationid -> shoot-3\n[5] markerlat -> 50.0925794844874\n[10] markerno -> 0\n[11] shootdate -> 2017-04-02\n[14] id -> 3\n}\n",
    "NSMapTable {\n[0] fstop -> 1.4\n[1] markerlong -> -122.992754392326\n[2] height -> 1\n[4] locationid -> shoot-3\n[5] markerlat -> 50.0922353295581\n[6] candles -> 0\n[7] candelas -> 0\n[11] distance -> 45\n[12] shootdate -> 2017-04-02\n[15] asa -> 25\n[16] shutter -> 24\n[26] markerno -> 1\n[27] tolight -> 0\n[30] id -> 3\n[31] color -> -14534267\n}\n",
    "NSMapTable {\n[0] fstop -> 1.4\n[1] markerlong -> -122.992754392326\n[2] height -> 1\n[4] locationid -> shoot-3\n[5] markerlat -> 50.0922353295581\n[6] candles -> 0\n[7] candelas -> 0\n[11] distance -> 45\n[12] shootdate -> 2017-04-02\n[15] asa -> 25\n[16] shutter -> 24\n[26] markerno -> 1\n[27] tolight -> 0\n[30] id -> 3\n[31] color -> -14534267\n}\n"
)>

What is happening here?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I've tested it with this code and I see two items:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   NavControl = Nav
   Page1.Initialize("Page1")
   Page1.Title = "Page 1"
   Page1.RootPanel.Color = Colors.White
   NavControl.ShowPage(Page1)
   Dim p As JSONParser
   p.Initialize($"[{
  "locationid": "shoot",
  "shootdate": "2017-04-02",
  "markerno": "0",
  "id": "2",
  "markerlong": "-122.993092350662",
  "uom": "Meter",
  "markerlat": "50.0925794844874"
}, {
  "tolight": "0",
  "id": "2",
  "color": "-14534267",
  "candles": "0",
  "shutter": "24",
  "locationid": "shoot",
  "markerno": "1",
  "fstop": "1.4",
  "candelas": "0",
  "asa": "25",
  "markerlong": "-122.992754392326",
  "height": "1",
  "distance": "45",
  "shootdate": "2017-04-02",
  "markerlat": "50.0922353295581"
}]"$)
   Log(p.NextArray)
End Sub
 
Upvote 0
Top