Reputation: 567
I want to parse Json
response:
client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
Any suggestion how to do that ?
Upvotes: 0
Views: 2731
Reputation: 8334
You can use json-simple
https://code.google.com/p/json-simple/
If you use maven
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
Then in your code
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);
// get a String from the JSON object
String firstName = (String) jsonObject.get("firstname");
System.out.println("The first name is: " + firstName);
Here there is an example
http://examples.javacodegeeks.com/core-java/json/java-json-parser-example/
Upvotes: 2