我有一个 JSON 字符串
[
{"created_at":"Thu Jan 24 07:27:12 +0000 2013",
"id":294345590119227392,
"user":{
"id":213539531,
"name":"Hamid",
"screen_name":"HamidMirGEO",
},
"retweeted":false
}]
使用以下代码解析
InputStream is = this.getResources().openRawResource(R.raw.jsontwitter);
byte [] buffer = new byte[is.available()];
while (is.read(buffer) != -1);
String jsontext = new String(buffer);
JSONArray entries = new JSONArray(jsontext);
for (i=0;i<entries.length();i++)
{
JSONObject post = entries.getJSONObject(i);
x += "Date:" + post.getString("created_at") + "\n";
x += "Post:" + post.getString("text") + "\n\n";
x += "Pp:" + post.getString("screen_name") + "\n\n";//error reading this
}
成功解析前两个,但在读取第二个大括号 {} 中的数据时遇到问题;对此的任何解决方案。