【问题标题】:Android Json passing issueAndroid Json传递问题
【发布时间】:2013-11-26 18:53:53
【问题描述】:

我需要从我的 android 应用程序访问 json 数据。为此,我开发了代码。现在我有一个小问题。但我无法解决它。它给了我一个类似图像的错误:

并打印我的 json 数据,它喜欢这样。

这是我的代码。

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

谁能帮帮我。

【问题讨论】:

标签: android json


【解决方案1】:

看来你忘了先获取 json 对象

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

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

【讨论】:

  • 嘿。谢谢。我不知道我怎么会错过它。总之非常感谢
【解决方案2】:
{ // json object node 
    "yammer": { // json object yammer
        "date": "2012-02-03", // string
        "description": "Lazdsasd",
        "title": "xzx"
    }
}

解析

 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();
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-12
    • 1970-01-01
    • 2021-06-02
    • 2016-10-11
    • 1970-01-01
    相关资源
    最近更新 更多