Android Question Array to string

giada

Member
Hi,
i have an array in a string:
s = "[1,2]"
how can i extract the 2 value?

The problem start from a json:

{"config":["Biccio",0,0,[40,50,120,140],[40,50,120,140],[40,50,120,140],[40,50,120,140],[40,50,120,140],[40,50,120,140],0]}

and i extract different values:

B4X:
    Dim parser As JSONParser
    parser.Initialize(s)
    Dim RootTemp As Map = parser.NextObject
    Dim config As List = RootTemp.Get("config")
    For Each colconfig As String In config
        Log(colconfig)
    Next

Each colconfig is a string...
 

udg

Expert
Licensed User
Longtime User
Assuming a fixed scheme in your JSON (this means there's no safenet, so the following is just to illustrate a concept):
B4X:
Dim config As List = RootTemp.Get("config")
Dim FirsList as List = config.get(3)
For Each item As String In FirsList
        Log(item)
Next
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
If it's an option to improve the input json, I would absolutely do that as the first action.
 
Upvote 0
Top