Hello,
i have to parse several json array, every array is different in size and elements so for a temporary test i created as many subs as many array i have to parse, this solution is muddy many maps, many variables difficult to mantain!
I have over 20 different types of array in my app and making so many subs with so many variables quickly became a mess!
I'd like to make a unique sub that manage all my json array and assign the values to the vars in a smart manner (easy to recognize)
how would you do this ?
Here just two of these subs from the muddy solution:
Thank you
i have to parse several json array, every array is different in size and elements so for a temporary test i created as many subs as many array i have to parse, this solution is muddy many maps, many variables difficult to mantain!
I have over 20 different types of array in my app and making so many subs with so many variables quickly became a mess!
I'd like to make a unique sub that manage all my json array and assign the values to the vars in a smart manner (easy to recognize)
how would you do this ?
Here just two of these subs from the muddy solution:
B4X:
Sub ParseJSON_1(srv_data As String)
Dim map01 As Map
map01.Initialize
jsonParse.Initialize(srv_data)
map01 = jsonParse.NextObject
s_data1= map01.get("s_data1")
s_data2= map01.get("s_data2")
End Sub
Sub parseJSON_2(srv_data As String)
Dim map03 As Map
map03.Initialize
jsonParse.Initialize(srv_data)
map03 = jsonParse.NextObject
p_id = map03.get("id")
p_data_1 = map03.get("p_data1")
p_data_2 = map03.get("p_data2")
p_data_3 = map03.get("p_data3")
p_data_4 = map03.get("p_data4")
p_data_5 = map03.get("p_data5")
p_data_6 = map03.get("p_data6")
'There are other 15 subs like this
End Sub
Thank you