I am running jokhttputils2 and json parser to get a json string from an online database.
I have a Tableview on my java app which i want to populate with the data received in the json string.
I am running following code for that
in the log i can see that i have got the following json string back from online database
[{"itemid":"1","itemname":"chicken biryani","itemprice":"20"},{"itemid":"2","itemname":"mutton biryani","itemprice":"25"},{"itemid":"3","itemname":"rice","itemprice":"10"},{"itemid":"4","itemname":"chicken qorma","itemprice":"15"},{"itemid":"5","itemname":"mutton qorma","itemprice":"25"},{"itemid":"6","itemname":"naan","itemprice":"2"},{"itemid":"7","itemname":"vegetable","itemprice":"8"},{"itemid":"8","itemname":"daal","itemprice":"8"},{"itemid":"9","itemname":"egg","itemprice":"5"},{"itemid":"10","itemname":"egg sandwich","itemprice":"10"},{"itemid":"11","itemname":"tea","itemprice":"1"},{"itemid":"12","itemname":"coffee","itemprice":"3"},{"itemid":"13","itemname":"sweet","itemprice":"10"},{"itemid":"14","itemname":"donut","itemprice":"5"},{"itemid":"15","itemname":"water","itemprice":"1"},{"itemid":"16","itemname":"pizza","itemprice":"30"},{"itemid":"17","itemname":"ice cream","itemprice":"7"}]
however the tableview is not getting populated it is giving me a casting error as i am getting a list of map items from onlie server, i have tried to put the Table list also in Tableview but it is also giving error
I have a Tableview on my java app which i want to populate with the data received in the json string.
I am running following code for that
B4X:
Sub loadlistview
Dim Table As List
Dim p As JSONParser
Dim res As String
Dim j As HttpJob
Dim m1 As Map
j.Initialize("", Me)
j.Download("http://saeedhassan.atwebpages.com/r.php")
Wait For (j) jobdone (j As HttpJob)
If j.Success Then
res = j.GetString
Log(res)
p.Initialize(res)
Table = p.NextArray
TableView1.SetColumns(Array As String("ID", "NAME", "PRICE"))
TableView1.Items.Add(p.NextArray)
[{"itemid":"1","itemname":"chicken biryani","itemprice":"20"},{"itemid":"2","itemname":"mutton biryani","itemprice":"25"},{"itemid":"3","itemname":"rice","itemprice":"10"},{"itemid":"4","itemname":"chicken qorma","itemprice":"15"},{"itemid":"5","itemname":"mutton qorma","itemprice":"25"},{"itemid":"6","itemname":"naan","itemprice":"2"},{"itemid":"7","itemname":"vegetable","itemprice":"8"},{"itemid":"8","itemname":"daal","itemprice":"8"},{"itemid":"9","itemname":"egg","itemprice":"5"},{"itemid":"10","itemname":"egg sandwich","itemprice":"10"},{"itemid":"11","itemname":"tea","itemprice":"1"},{"itemid":"12","itemname":"coffee","itemprice":"3"},{"itemid":"13","itemname":"sweet","itemprice":"10"},{"itemid":"14","itemname":"donut","itemprice":"5"},{"itemid":"15","itemname":"water","itemprice":"1"},{"itemid":"16","itemname":"pizza","itemprice":"30"},{"itemid":"17","itemname":"ice cream","itemprice":"7"}]
however the tableview is not getting populated it is giving me a casting error as i am getting a list of map items from onlie server, i have tried to put the Table list also in Tableview but it is also giving error