Dim jg As JsonGenerator
Dim m As Map = CreateMap("AdminGateWebLink": "http://....", "AdminUserWebLink": "http://...", _
"GateList": Array (CreateMap("Id": 102, ...), _
CreateMap("Id": 105, ...)))
jg.Initialize(m)
log(jg.ToPrettyString(4))
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}]}
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}]}
It is critical for developers to understand how the Map collection works. I recommend you to watch the collections video tutorial: https://b4x.com/etp.html
B4X:
Dim names As List
names.Initialize
For i = 0 To 1
names.Add(CreateMap("name": i,"IC":i))
Next
GroupMap.Put("properties", names)