0

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 ?

marekful
  • 14,986
  • 6
  • 37
  • 59
Verint Verint
  • 557
  • 1
  • 7
  • 19
  • 6
    Possible duplicate of [How do I parse JSON from a Java HTTPResponse?](http://stackoverflow.com/questions/2845599/how-do-i-parse-json-from-a-java-httpresponse) – Raf Dec 07 '15 at 16:17

1 Answers1

2

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/

reos
  • 8,766
  • 6
  • 28
  • 34