Reputation: 315
I successfully opened Httpclient
connection. Now I want to select data from JSON and show it in a list. I googled it from half day but can't find any help. A sample project or code snippet would be really helpful.
Upvotes: 1
Views: 1283
Reputation: 44919
In the past I've used gson to parse JSON. The org.json
package provided in the SDK seems a little low-level.
Now I want to select data from JSON and show it in a list.
When you say "select data" do you mean use queries to retrieve subsets of your data? jxpath looks like an interesting solution. If you're just displaying the entire JSON data then you should be able to simply wrap gson's output in an adapter.
I googled it from half day but can't find any help.
The last one would have led you to this question, of which yours is an exact duplicate.
A sample project or code snippet would be really helpful.
Examples abound! From the above search links:
Upvotes: 2
Reputation: 9777
You'll have to use http://developer.android.com/reference/org/json/JSONTokener.html or something similar to decode your JSON data.
After doing that you need to update your list model on your list view.
I'm under the impression that for your application http://developer.android.com/reference/android/widget/ArrayAdapter.html might suit your needs.
If you already have an array adapter, you probably just need to update that adapter.
I don't have specifics on that though. Hopefully this will put you on the right track.
Upvotes: 0