I am trying to consume PHP Web service with JSON in android
I got response data from server as
string(170) "["14","Samsung","1","15","Nokia","1","16","Sony Ericson","1","18","LG","1","19","Iphone","1","21","HTC","1","22","Motorola","1","23","Micromax","1","41","BlackBerry","1"]"
How should i parse it to show it on a ListView.I am familiar about how to show data on ListView by creating custom adapter but I am unable to parse this output.Please help
I followed this tutorial to access PHP Web Service
http://www.codeproject.com/Articles/267023/Send-and-receive-json-between-android-and-php
Give me some reference.
Any help is appreciated.
Thank you…
Alos I would like to know what is the proper format of JSONArray generated at php side ??
It is valid but weird json response.
When you parse this json you will get 27 values.
14, samsung, 1, 15, nokia…
But it seems every 3 item is an object like
“14,samsung,1”
“15,nokia,1”.
And that json doesn’t reflect that.
With an online json parser like this, you can see what result you can:
http://jsonviewer.stack.hu/And you can parse that json like this:
Log your array to see what you got:
Results:
And for the server site:
Normally that json had to be like this..