Android 解析JSON数据会产生JSONEXception:内容没有值

Android 解析JSON数据会产生JSONEXception:内容没有值,android,json,Android,Json,我试图解析JSON数据,但遇到了一个问题 JSON: 我的代码: try { JSONArray json_posts = json.getJSONArray("posts"); for(int i = 0; i < json_posts.length(); i++) { JSONObject posts = json_posts.getJSONObject(i); String post_id = posts.getSt

我试图解析JSON数据,但遇到了一个问题

JSON:

我的代码:

try {
JSONArray json_posts = json.getJSONArray("posts");
for(int i = 0; i < json_posts.length(); i++) {                          
    JSONObject posts = json_posts.getJSONObject(i);
    String post_id = posts.getString("post_id");

    String post_content = posts.getString("content");
试试看{
JSONArray json_posts=json.getJSONArray(“posts”);
对于(inti=0;i
错误:

JSONEXception:内容没有值


不确定您是否正在解析完全相同的JSON,但如果是相同的(不是复制错误),您应该检查


请添加logcat。

我更喜欢使用Google GSON库解析Json。试试看:post logcat error message..org.Json.JSONException:No value for content您是否仔细检查了这是否与您正在处理的字符串相同?因为如果是,您就有一个错误。您必须有一个结束的JSONArray括号,然后是另一个JSONObject closing括号。
try {
JSONArray json_posts = json.getJSONArray("posts");
for(int i = 0; i < json_posts.length(); i++) {                          
    JSONObject posts = json_posts.getJSONObject(i);
    String post_id = posts.getString("post_id");

    String post_content = posts.getString("content");