iOS Question JSONParser and data type

Semen Matusovskiy

Well-Known Member
Licensed User
I convert B4A code to B4I and noticed one incompatibility

B4A interpretates 1234567890 as Int, 12345678901 (this is more than maximum Int) as Long. I can understand this logic.

But why in B4i both values are Long ? Not a problem, but is able to confuse.

B4X:
    Dim stringJSON             As String = "{""value1"":1234567890,""value2"":12345678901}"
    Dim jsonparserJSONParser   As JSONParser

    jsonparserJSONParser.Initialize (stringJSON)
      
    Dim mapJSON                                                                 As Map
    Dim objectInstance                                                          As Object
  
    mapJSON = jsonparserJSONParser.NextObject
  
    objectInstance = mapJSON.Get ("value1")
    If (objectInstance Is Int)  Then Log ("value1 Is Int")
    If (objectInstance Is Long) Then Log ("value1 Is Long")
  
    objectInstance = mapJSON.Get ("value2")
    If (objectInstance Is Int)  Then Log ("value2 Is Int")
    If (objectInstance Is Long) Then Log ("value2 Is Long")
 
Top