Unable to parse JSON object using Volley

浪尽此生 提交于 2021-02-17 07:11:32

问题


JSON file:

JSON FILE URL

i am looping through the "biller" Array to fetch all the object's where "billerCategory": is "Electricity". I am trying to get "paramName" value. But i am only getting 3 paramName values.

Response:

Code:

try {
                JSONArray biller = response.getJSONArray("biller");

                Log.d(TAG, biller.toString());

                // Loop through biller Array and find billerID
                for (int i = 0; i < biller.length(); i++)
                {
                    JSONObject billerObj = (JSONObject) biller.get(i);
                    String category = billerObj.getString("billerCategory");


                    //Log.d(TAG, category);

                    if (category.equalsIgnoreCase("Electricity")){

                        JSONObject paraminput = billerObj.getJSONObject("billerInputParams");
                        JSONObject paramInfo = paraminput.getJSONObject("paramInfo");
                        String paramName = paramInfo.getString("paramName");


                        Log.d(TAG, paramName);

                    }
                }
            } 

回答1:


An exception has occured. Search for 'TORR00000SUR04'. It happened that "paramInfo" is an JSONArray at that point.



来源:https://stackoverflow.com/questions/60574258/unable-to-parse-json-object-using-volley

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!