B4J Question [solved] problem with array data in json

MarkusR

Well-Known Member
Licensed User
maybe is someone more firm in json parsing
i have this json and need iterate this array(list) "List_Packages"
and the data there "Pos_A_mm" and below "X","Y","Z"

my attempt
B4X:
    Dim J As JSONParser
    J.Initialize(JSON)
        
    Dim Map1 As Map
    Map1 = J.NextObject
        
    Dim Packages As Map
    Packages = Map1.Get("List_Packages")
{
"Ez_Cnt": {
"Description": null,
"Length_mm": 0,
"Width_mm": 0,
"Height_mm": 0,
"Net_kg": 0,
"Tare_kg": 0,
"Flag_AddTareToCenterOfGravity": false,
"Door_Length_mm": 0,
"Door_Width_mm": 0,
"Door_Height_mm": 0,
"Door_Position_T_S_B": null,
"ID": null
},
"List_Packages": [
{
"Description": "Some human readable package description",
"Pos_A_mm": {
"X": 100,
"Y": 200,
"Z": 0
},
"Pos_G_mm": {
"X": 1100,
"Y": 1200,
"Z": 1300
},
"Package_color": "255, 128, 64",
"ID": "PC20180412#1234567"
},
{
"Description": "P104711\/001",
"Pos_A_mm": {
"X": 100,
"Y": 1200,
"Z": 0
},
"Pos_G_mm": {
"X": 1100,
"Y": 2200,
"Z": 1300
},
"Package_color": "128, 64, 255",
"ID": "BoxCadBarcode preferred"
},
{
"Description": null,
"Pos_A_mm": null,
"Pos_G_mm": null,
"Package_color": "",
"ID": null
}
],
"CoG": {
"Pos_mm": null
}
}
 

MarkusR

Well-Known Member
Licensed User
i think i solved it myself with
B4X:
    Dim Packages As List
    Packages = Map1.Get("List_Packages")
 

MarkusR

Well-Known Member
Licensed User
@OliverA ha ha, as i saw your comment i remember i saw this online tool months ago but i forget this nice tool existence.
thank you.
 
Top