Android Question JSONPARSER giving strange Columns order depending on device

infow

Member
Licensed User
Longtime User
I´m using this simple code to show a JSON text into a webview, but the same code it´s working diferent on each device, the problem it´s the columns order, in Cellphones work well and comes with the JSON field order, in tablets with 4.4.2 Android version it´s parsed ok but the columns come with an aleatory order...

Can anyone give me a help...

B4X:
    Dim parser As JSONParser
    parser.Initialize("[{""DESCR_GR_IND"":""xxx"",""COD_PROD"":""10015848"",""DESCR_PROD"":""xxxx 5MG - 13 A  25KG - 03 COMPR"",""201611"":0.0000,""201612"":0.0000,""201701"":0.0000,""201702"":0.0000,""201703"":0.0000,""201704"":0.0000,""201705"":1.0000,""201706"":0.0000,""201708"":0.0000,""201709"":1.0000,""201710"":1.0000},{""DESCR_GR_IND"":""xxxx"",""COD_PROD"":""10015849"",""DESCR_PROD"":""xxxx 10MG - 26 A 5KG - 03 COMPR"",""201611"":0.0000,""201612"":0.0000,""201701"":0.0000,""201702"":0.0000,""201703"":1.0000,""201704"":0.0000,""201705"":1.0000,""201706"":0.0000,""201708"":2.0000,""201709"":0.0000,""201710"":1.0000}]")
    Dim rows As List
    rows = parser.NextArray
  
    Dim mp As Map
    Dim m As Map
    Colunas.Initialize
    m = rows.Get(0)
    For z = 0 To m.Size -1
        Colunas.Put(z,m.GetKeyAt(z))
    Next

JSON:
B4X:
[{"DESCR_GR_IND":"xxx","COD_PROD":"10015848","DESCR_PROD":"xxx 5MG - 1,3 A  2,5KG - 03 COMPR","2016/11":0.0000,"2016/12":0.0000,"2017/01":0.0000,"2017/02":0.0000,"2017/03":0.0000,"2017/04":0.0000,"2017/05":1.0000,"2017/06":0.0000,"2017/08":0.0000,"2017/09":1.0000,"2017/10":1.0000},{"DESCR_GR_IND":"xxx","COD_PROD":"10015849","DESCR_PROD":"xxx 10MG - 2,6 A 5KG - 03 COMPR","2016/11":0.0000,"2016/12":0.0000,"2017/01":0.0000,"2017/02":0.0000,"2017/03":1.0000,"2017/04":0.0000,"2017/05":1.0000,"2017/06":0.0000,"2017/08":2.0000,"2017/09":0.0000,"2017/10":1.0000}]
 
Last edited:

infow

Member
Licensed User
Longtime User
There is a way to show the data as I get it, from the text? Following the order? I created a dynamic display of the data... just need that it follow the order...
 
Upvote 0

infow

Member
Licensed User
Longtime User
There is no way to avoid this? I will have to abandon all my work that I used JSON as a way to send the data...
 
Upvote 0

infow

Member
Licensed User
Longtime User
Why? just use the key names, that will need some extra code but it can be done.

Some people just like drama I think :D

That was easy, but I did a dinamic display of data, there is no way to declare... Some querys, even the columns are pivots, and the query generate dinamic columns too...
 
Upvote 0
Top