Android Question map to json conversion

Discussion in 'Android Questions' started by laomms, Apr 13, 2019.

Similar threads

Games [XUI2D] Example Pack
B4A Tutorial Android JSON tutorial
B4A Tutorial Text files
B4A Tutorial Google Maps
B4A Question Write 2 map views to a single txt file
  1. laomms

    laomms Member Licensed User

    I want send json string to webrequest:
    {'Type':'AAA','param':[{'paramName':'C1','paramValue':'25'}],'variables':{}}

    Code:
    Dim Map1 As Map
                Map1.Initialize
                Map1.Clear          
                
    Dim Map2 As Map
                Map2.Initialize
                Map2.Clear
                Map1.Put(
    "Type","AAA")
                Map1.Put(
    "param",Map2)          
                Map2.Put(
    "paramName","C1")
                Map2.Put(
    "paramValue","25")
                Map1.Put(
    "variables","{}")
                
    Dim JSON As JSONGenerator
                JSON.Initialize(Map1)
                data=   JSON.ToString
    Is right?
     
  2. DonManfred

    DonManfred Expert Licensed User

    i guess it should be

    Code:
    dim l as list
    l.initialize
    Map1.Put(
    "variables",l)
    did you get any error? Why you did not posted the error you got?
     
  3. laomms

    laomms Member Licensed User

    it's show error:
    Innermost cause of throwable is Cannot deserialize instance of java.util.ArrayList out of START_OBJECT token\n at [Source: (PushbackInputStream); line: 1, column: 34] (through reference chain: com.jacada.is.rest.beans.requests.InteractionNavigationRequest[\"param\"])"

    the error come from target website.

    I can post normal use below code:
    Code:
    jsonText = "{""Type"":""AAA"",""param"":[{""paramName"":""C1"",""paramValue"":""25""}],""variables"":{}}"
    I want to know how to made it in map ways。
    {"Type":"NEXT","AAA":{"paramName":"C1","paramValue":"25"},"variables":"{}"}
    it's no "[]" punctuation
     
    Last edited: Apr 13, 2019
  4. laomms

    laomms Member Licensed User

    ok. got it

    Map1.Put("param",Array(Map2))
     
    Last edited: Apr 13, 2019
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