Parsing JSON from url with exception: Error parsing data org.json.JSONException: Unterminated array at character 115

后端 未结 3 1086
遇见更好的自我
遇见更好的自我 2020-12-22 05:40

I\'m parsing this url and I\'ve got an exception and don\'t know how to skip it over... I need to get only names of 100 the most popular apps. There is key \"im:name\" and i

3条回答
  •  自闭症患者
    2020-12-22 06:05

    You are not accessing the values the right way, check this:

    JsonParser jParser = new JsonParser();
    JSONObject json = jParser.getJSONFromUrl(jsonStringUrl);
    JSONObject feeds = json.getJSONObject("feed");
    
    dataJsonArr = feeds.getJSONArray("entry");
    for (int i = 0; i < dataJsonArr.length(); i++) {
        JSONObject c = dataJsonArr.getJSONObject(i);
        String name = c.getString("im:name");
        Log.d("mylog", "name = " + name);
    }
    

    You probably want to append this data into an array list, otherwise you would be overwriting these variables.

    Please note org.json is a limited library i have personally experienced its limitation when the json data is too large.

    I suggest you to ditch it and use GSON or jackson which are fare more advanced.

提交回复
热议问题