Android Question map to json conversion

laomms

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

B4X:
            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?
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

laomms

Member
Licensed User
Longtime 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:
B4X:
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:
Upvote 0
Top