Hi, i have this case where i can parse json with more than one data on. but when i try one only dows not work.
json with only one
json with more than one
and here is my parse code
i relly dont know what is happening. this only happen if dd have only one item.
Victor
json with only one
B4X:
Dim DD As String = $"
{"DatoSorteo":
{"descripcion":"BINGO MILLONARIO",
"fechasorteo":"2018-11-11",
"codigo":"BINGO_M",
"acumulado":"0",
"id":"35",
"numerosorteo":"16",
"horasorteo":"15:35:00"}
}
"$
json with more than one
B4X:
Dim DD As String = $"{
"DatoSorteo": [
{
"descripcion": "BINGO INMOBILIARIO",
"fechasorteo": "2018-07-10",
"codigo": "BINGO_I",
"acumulado": "23000",
"id": "2",
"numerosorteo": "1",
"horasorteo": "15:35:00"
},
{
"descripcion": "BINGO MILLONARIO",
"fechasorteo": "2018-07-19",
"codigo": "BINGO_M",
"acumulado": "150000",
"id": "3",
"numerosorteo": "1",
"horasorteo": "15:35:00"
},
{
"descripcion": "BINGO CAR",
"fechasorteo": "2018-08-20",
"codigo": "BINGO_C",
"acumulado": "100000",
"id": "20",
"numerosorteo": "1",
"horasorteo": "15:35:00"
}
]
}"$
and here is my parse code
B4X:
Dim parser As JSONParser
parser.Initialize(DD)
Dim root As Map = parser.NextObject
Dim colDatoSorteo As List = root.Get("DatoSorteo")
For Each colDatoSorteo As Map In XDatoSorteo
Log(colDatoSorteo.Get("descripcion"))
Log(colDatoSorteo.Get("fechasorteo"))
Log(colDatoSorteo.Get("codigo"))
Log(colDatoSorteo.Get("acumulado"))
Log(colDatoSorteo.Get("id"))
Log(colDatoSorteo.Get("numerosorteo"))
Log(colDatoSorteo.Get("horasorteo"))
Next
i relly dont know what is happening. this only happen if dd have only one item.
Victor