-1

Possible Duplicate:
Parsing JSON from URL
How to get JSON data from an url in Java?

I have an URL from which I am getting JSON data in an array that I want to parse into string using java. which library is used for parsing data from JSON.

The data which I am getting in an array from URL is like below.

[
{
"id":4,
"firstName":"varun",
"lastName":"",
"addressLine1":"new delhi",
"addressLine2":"",
"landmark":"",
"locality":"AIRPORT",
"pincode":"700003"
}]

Array has no name.

Community
  • 1
  • 1
yatinbc
  • 605
  • 3
  • 16
  • 37
  • possible duplicate of [Parsing JSON from URL](http://stackoverflow.com/questions/7467568/parsing-json-from-url) or http://stackoverflow.com/questions/9994676/how-to-get-json-data-from-an-url-in-java?rq=1 or any of the tenths of questions on Json + Java in SO. – pcalcao Jan 02 '13 at 10:55
  • Exact duplicate of http://stackoverflow.com/q/9994676/1065525 – Alexis Pigeon Jan 02 '13 at 10:56
  • question is duplicate but solution dosen't satifies my problem – yatinbc Jan 02 '13 at 10:58
  • I should post a question: Can I throw a dead cat and not hit a question regarding how to parse JSON with Java? – ppeterka Jan 02 '13 at 11:15
  • 1
    what's wrong with the answers of the other questions? – Alexis Pigeon Jan 02 '13 at 11:15
  • problem is only the data which I am getting in an array from URL has no name it simply in [], like above, so code snippet from which i gone through couldn't use with my case. – yatinbc Jan 02 '13 at 12:34
  • URL I gone through is :http://blog.eviac.com/2011/07/parsing-json-comes-as-response-to-web.html – yatinbc Jan 02 '13 at 12:35

1 Answers1

0

There are many, one of them is Jackson:

ObjectMapper mapper = new ObjectMapper();

// json will contain the JSON in a tree
JsonNode json = mapper.readTree(yourURLObject);
fge
  • 119,121
  • 33
  • 254
  • 329