Deepu Mandy
Deepu Mandy

Reputation: 117

how do i read id value using java language?

     {
       "id": "2345631223",
       "name": "MyFbAcc",
       "picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4  /373042_396504583708761_162084_s.jpg",
        "link": "http://www.facebook.com/MyFbAcc",
        "likes": 70,
        "cover": {
          "cover_id": 434873094856,
          "source": "http://a3.sphotos.ak.fbcdn.net/hphotos-ak-snc7/s720x720/396014_493579484001270_1795_n.jpg",
          "offset_y": 0
     }

Normal Xml files I used to read xml parsing/DocumentBuilderFactory, which xml consists of tags, etc, but here all are represent in " ". how do I get read the id value?

id=2345631223. Any help most welcome?

Upvotes: 0

Views: 124

Answers (2)

Vinay W
Vinay W

Reputation: 10190

if i suppose you are making the JSON object with a String

        String jString="{"name":"value"};
        JSONObject jObject = new JSONObject(jString);

then you can retrieve the value form the name-value pairs like

        String valueFromJSON= jObject.getString("name");

Upvotes: 0

Nermeen
Nermeen

Reputation: 15973

Using JSON..

JSONObject object = new JSONObject(yourString);
String id = object.getString("id");

Upvotes: 2

Related Questions