iOS Question JSONParser and data type

Discussion in 'iOS Questions' started by Semen Matusovskiy, Apr 27, 2019.

  1. Semen Matusovskiy

    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.

    Code:
    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")
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    This is how the OS native json parser behaves.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice