-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.

Coderji
  • 7,655
  • 5
  • 37
  • 51
Lahiruzz
  • 665
  • 1
  • 12
  • 24
  • 1
    i believe you have to see my answer here to know more about `json` and how to parse it http://stackoverflow.com/questions/19746800/android-parse-jsonobject/19747171#19747171 – Noob Nov 26 '13 at 19:05

2 Answers2

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);
maximus
  • 716
  • 7
  • 18
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();
 }
Raghunandan
  • 132,755
  • 26
  • 225
  • 256