Android Question JSON & Maps

Discussion in 'Android Questions' started by LucaMs, Jun 25, 2018.

Tags:
  1. LucaMs

    LucaMs Expert Licensed User

    JSON generator / parser seems to convert maps' keys to string:

    Code:
    Dim mapSource As Map
        mapSource.Initialize
        
    Dim i As Int
        
    For i = 1 To 3
            mapSource.Put(i,i)
        
    Next
        
    Dim jg As JSONGenerator
        jg.Initialize(mapSource)
        
    Dim sJSON As String = jg.ToString
        
        
        
    Dim jp As JSONParser
        jp.Initialize(sJSON)
        
    Dim mapOther As Map = jp.NextObject
        
    For i = 0 To mapOther.Size - 1
            
    Log(i & TAB & mapOther.GetKeyAt(i) & TAB & GetType(mapOther.GetKeyAt(i)))
            
    Log(i & TAB & mapOther.GetValueAt(i) & TAB & GetType(mapOther.GetValueAt(i)))
        
    Next
    log:

    0 3 java.lang.String
    0 3 java.lang.Integer
    1 2 java.lang.String
    1 2 java.lang.Integer
    2 1 java.lang.String
    2 1 java.lang.Integer


    Am I doing something wrong or is it so?
     
  2. KMatle

    KMatle Expert Licensed User

    Erel and LucaMs like this.
  3. LucaMs

    LucaMs Expert Licensed User

    :(

    ok.
     
  4. KMatle

    KMatle Expert Licensed User

    What do you want to achieve? For sure there's a solution.
     
    LucaMs likes this.
  5. LucaMs

    LucaMs Expert Licensed User

    send a map that has integers as keys. I understood that it can not be done; I'll have to convert them to string and vice versa when I receive the map.

    Thank you.
     
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