How does one consume web services that return JSON data in th开发者_开发知识库e response?
I am trying to build an app around twitter's API (for ex: http://search.twitter.com/search.json?q=shivkumarganesh)
I have a Twitter URL . Now this when queried returns a JSON file. Can you help me to identify that how can I consume this in order to retrieve the results. I want to build an application around it. Please let me koow. I am using Netbeans 7 as my IDE so if there is a tutorial for such a thing in Netbeans and that too in Java then please let me know.
You have 2 choices here: 1. Consume the twitter API on your server 2. Consume the API in the client
The fastest to roll out would be number 2 since you'll just fire an ajax request to the API and consume the JSON response.
Consuming it on your server(presumably a j2ee application) will require a JSON Serializer/Deserialzer. There are several available(see json.org) but I personally prefer flexjson. google-gson is also good.
You're just needing to decode the JSON, so look into Gson: http://code.google.com/p/google-gson/
精彩评论