-1

I need to access json data from my android app. for that i have developed code. now i have small issue. but i can not solved it. it gives me a error like in image:

enter image description here

and print my json data and it likes this.

enter image description here

and this is my code.

String date = c.getString(TAG_DATE);                
String description = c.getString(TAG_DESCRIPTION);  
String title = c.getString(TAG_TITLE);

can someone please help me.

1

2 Answers 2

1

Look like you forgot to get json object first

JSONObject o = c.getJSONObject("yammer");

String date = o.getString(TAG_DATE);
String description = o.getString(TAG_DESCRIPTION);
String title = o.getString(TAG_TITLE);
Sign up to request clarification or add additional context in comments.

1 Comment

Hey. Thanks. i don't know how do i missed it. anyway thaks very much
1
{ // json object node 
    "yammer": { // json object yammer
        "date": "2012-02-03", // string
        "description": "Lazdsasd",
        "title": "xzx"
    }
}

To parse

 try
 {
   JSONObject jb = new JSONObject("your json string");
   String yammer = jb.getString("yammer");
   JSONObject jb1 = new JSONObject(yammer);    
   String date = jb1.getString("date");
   Log.i("date","............"+date);
   String description = jb1.getString("description");
   String title = jb1.getString("title");
 }catch(Exception e)
 {
      e.printStackTrace();
 }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.