madru Active Member Licensed User Longtime User Apr 2, 2020 #1 good afternoon, can somebody help me to generate this JSON structure.? JSON: { "vehicle": [ { "Position": { "dyn": 0.0, "lat": 12.34567890000000, "lon": 23.45678900000000 }, "channel": 1234, "identification": { "Type": "loader", "manufacturer": "MAN", "model": "TGX" } } ], "level": 100, "timestamp": 1585835426726 }
good afternoon, can somebody help me to generate this JSON structure.? JSON: { "vehicle": [ { "Position": { "dyn": 0.0, "lat": 12.34567890000000, "lon": 23.45678900000000 }, "channel": 1234, "identification": { "Type": "loader", "manufacturer": "MAN", "model": "TGX" } } ], "level": 100, "timestamp": 1585835426726 }
DonManfred Expert Licensed User Longtime User Apr 2, 2020 #2 What have you tried so far???? Have you checked the methods jsongenerator has? Let me answer for you; NO, you did not. A tip: the jsongenerator can be initialized with giving a MAP. Upvote 0
What have you tried so far???? Have you checked the methods jsongenerator has? Let me answer for you; NO, you did not. A tip: the jsongenerator can be initialized with giving a MAP.
Erel B4X founder Staff member Licensed User Longtime User Apr 2, 2020 #3 Untested code: B4X: Dim m As Map = CreateMap("vehicle": Array ( _ CreateMap("position": CreateMap("dyn": 0, "lat": 12, "lon": 23), "channel": 1234, ... DIm jg As JsonGenerator jg.Initialize(m) log(jg.ToPrettyString(4)) Upvote 0
Untested code: B4X: Dim m As Map = CreateMap("vehicle": Array ( _ CreateMap("position": CreateMap("dyn": 0, "lat": 12, "lon": 23), "channel": 1234, ... DIm jg As JsonGenerator jg.Initialize(m) log(jg.ToPrettyString(4))
madru Active Member Licensed User Longtime User Apr 2, 2020 #4 Thx Erel, appreciate your help as always I missed the 'Array' adding the objects, ended up with instead of Upvote 0
Thx Erel, appreciate your help as always I missed the 'Array' adding the objects, ended up with instead of
Sandman Expert Licensed User Longtime User Apr 2, 2020 #5 Nice illustrations, how did you make them? Upvote 0
madru Active Member Licensed User Longtime User Apr 3, 2020 #6 Sandman said: Nice illustrations, how did you make them? Click to expand... JSON 2 HTML Upvote 0