简体   繁体   中英

Android Json Handling issue

I want to display updated_at data to user only if value of password in folder Array is null.

JSONArray jsonArray = object.getJSONArray("data");
                            for (int i = 0; i < jsonArray.length(); i++) {
                                JSONObject dataa = jsonArray.getJSONObject(i);


                                JSONArray jsonArray2 = dataa.getJSONArray("folder");
                                for (int i2 = 0; i2 < jsonArray.length(); i2++)
                                {
                                    JSONObject dataa2 = jsonArray2.getJSONObject(i2);
                                    String password = dataa2.getString("password");
                                    if (password.equals("null") || password.equals(null))
                                    {
                                        //Display data
                                    }
                                    else
                                    {
                                        // dont Display data
                                    }
}

在此处检查 Json 响应

Is there a way to do it?

Rectify your inner loop condition section.

JSONArray jsonArray2 = dataa.getJSONArray("folder");
for (int i2 = 0; i2 < jsonArray2.length(); i2++)
          {
              JSONObject dataa2 = jsonArray2.getJSONObject(i2);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM