Android Question how to get only 1 id in json

larprogramer

Member
Licensed User
i have problem. i want to get only id 2. who know tell me please...
{
"results": [
{
"id": 1,
"name": "Test"
},
{
"id": 2,
"name": "Beispiel"
},
{
"id": 3,
"name": "Sample"
}
]
}
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim results As List = root.Get("results")
For Each colresults As Map In results
 Dim name As String = colresults.Get("name")
 Dim id As Int = colresults.Get("id")
Next
If you want to get the second items. add a counter to the loop and remember the value you want.
 
Upvote 0

larprogramer

Member
Licensed User
B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As Map = parser.NextObject
Dim results As List = root.Get("results")
For Each colresults As Map In results
 Dim name As String = colresults.Get("name")
 Dim id As Int = colresults.Get("id")
Next
If you want to get the second items. add a counter to the loop and remember the value you want.
Thanks bro
 
Upvote 0
Top