Android如何解析json?有实例吗? jsonandroid数据实例 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 test Jsonobject{ "result":{ "code":0, "message":"message", "sucess":true}}Jsonobject json = test.getjsonobject("result");int code = json.getint("code");String message = json.getString("message");boolean sucess = json.getboolean("sucess") 看在你有80分的份上就给你弄个demo。 已经按照你的要求解析了数据,做好了demo,去下载吧http://download.csdn.net/detail/lulong1985/8287581 我刚做完一个项目,使用的是jackson ,感觉非常方便,推荐给你使用 谢谢。你这个好像有问题,文字是解析出来了,但是图片有问题。要是用listView去展示就好了。 恩恩,我刚刚看了你的json中的images是数组类型的,我开始以为是object,你改一下public static LinkedList<news> getFansParse(JSONArray jsonArray)这个方法就行public static LinkedList<news> getFansParse(JSONArray jsonArray) { JSONObject json = null; int len = jsonArray.length(); LinkedList<news> fans = new LinkedList<news>(); try { for (int i = 0; i < len; i++) { json = jsonArray.getJSONObject(i); news f = new news(); f.setGid(JsonParserTolls.getStr(json, "gid")); f.setTitle(JsonParserTolls.getStr(json, "title")); f.setTime(JsonParserTolls.getStr(json, "time")); f.setCommentNum(JsonParserTolls.getStr(json, "commentNum")); f.setFavoriteNum(JsonParserTolls.getStr(json, "favoriteNum")); f.setImageNum(JsonParserTolls.getStr(json, "imageNum")); JSONArray newjsonArray=JsonParserTolls.getJsonArray(json, "images"); String url=newjsonArray.getString(0); f.setImages(url); Log.e("ldebug", "newjsonArray" + url); fans.add(f); } } catch (JSONException e) { e.printStackTrace(); } return fans; } android 怎么支持语音聊天呢?? 安卓创建联系人失败 求助 Android XML解析问题 onDestory() 在android API文档,什么底下查 Bitmap 问题 程序里如果获取AndroidManifest.xml里的应用版本号 关于ListView 显示的问题 在线等!!!!! 【android SDK _ 时间】日历类获得指定日期的星期不正确? 按下home键后回到app后新生成了activity解决 Android stdio下载模拟机出现这样是怎么回事 有办法让每一个AlertDialog实例自身携带一个句柄(int)吗 android 如何使用.so库里文件
{
"result":{
"code":0,
"message":"message",
"sucess":true
}
}
Jsonobject json = test.getjsonobject("result");
int code = json.getint("code");
String message = json.getString("message");
boolean sucess = json.getboolean("sucess")
http://download.csdn.net/detail/lulong1985/8287581
要是用listView去展示就好了。
JSONObject json = null;
int len = jsonArray.length();
LinkedList<news> fans = new LinkedList<news>();
try {
for (int i = 0; i < len; i++) {
json = jsonArray.getJSONObject(i);
news f = new news();
f.setGid(JsonParserTolls.getStr(json, "gid"));
f.setTitle(JsonParserTolls.getStr(json, "title"));
f.setTime(JsonParserTolls.getStr(json, "time"));
f.setCommentNum(JsonParserTolls.getStr(json, "commentNum"));
f.setFavoriteNum(JsonParserTolls.getStr(json, "favoriteNum"));
f.setImageNum(JsonParserTolls.getStr(json, "imageNum"));
JSONArray newjsonArray=JsonParserTolls.getJsonArray(json, "images");
String url=newjsonArray.getString(0);
f.setImages(url);
Log.e("ldebug", "newjsonArray" + url);
fans.add(f);
}
} catch (JSONException e) {
e.printStackTrace();
}
return fans;
}