Android Question How to create Map

Calvin Yee

Member
Licensed User
I would like to create a map as per below.

All data is from sqlite. No hardcode on it.

Please advice.


{ "AdminGateWebLink":"http://qa.app.opengatebr.com/CompanyGate",
"AdminUserWebLink":"http://qa.app.opengatebr.com/User",
"ECommerceLink":"http://www.opengatebr.com/#!loja-e-carrinho/cq49",
"GateList": [
{"Id":102,"Name":"as","Url":"21321","Latitude":0,"Longitude":0},
{"Id":105,"Name":"olabug","Url":"189.54.67.252","Latitude":0,"Longitude":0},
{"Id":106,"Name":"pteste01","Url":"189.54.64.75","Latitude":0,"Longitude":0}
]
}
 

Calvin Yee

Member
Licensed User
"GateList": Array (CreateMap("Id": 102, ...), _
CreateMap("Id": 105, ...)))


For the GateList: this is a dynamics data will get from table. How to write the coding?
 

Calvin Yee

Member
Licensed User
this is my code:-
I want 2 rows of "properties". system only show 1 row.
Its only display one row.

Please advise.
B4X:
Dim GroupMap As Map
    GroupMap.Initialize
    GroupMap.Put("AdminGateWebLink","http://qa.app.opengatebr.com/CompanyGate")
    GroupMap.Put("AdminUserWebLink","http://qa.app.opengatebr.com/User")
    For i = 0 To 1
        GroupMap.Put("properties",Array( CreateMap("name": i,"IC":i)))
    Next
    Dim JSONGenerator As JSONGenerator
    JSONGenerator.Initialize(GroupMap)
    Dim JSONstring As String
    JSONstring = JSONGenerator.ToString
    Log(JSONstring)
Running above coding and show following output:-
{"AdminGateWebLink":"http:\/\/qa.app.opengatebr.com\/CompanyGate","AdminUserWebLink":"http:\/\/qa.app.opengatebr.com\/User","properties":[{"name":1,"IC":1}]}
 
Last edited:

Calvin Yee

Member
Licensed User
Thank Erel for advise.
I tested following

B4X:
Dim GroupMap As Map
    GroupMap.Initialize
    GroupMap.Put("AdminGateWebLink","http://qa.app.opengatebr.com/CompanyGate")
    GroupMap.Put("AdminUserWebLink","http://qa.app.opengatebr.com/User")
    For i = 0 To 1
        GroupMap.Put("properties",Array( CreateMap("name": i,"IC":i)))
    Next
    Dim JSONGenerator As JSONGenerator
    JSONGenerator.Initialize(GroupMap)
    Dim JSONstring As String
    JSONstring = JSONGenerator.ToString
    Log(JSONstring)
Running above coding and show following output:-
{"AdminGateWebLink":"http:\/\/qa.app.opengatebr.com\/CompanyGate","AdminUserWebLink":"http:\/\/qa.app.opengatebr.com\/User","properties":[{"name":1,"IC":1}]}
 
Top