Note that there are some explanatory texts on larger screens.

plurals
  1. POJSON parse image came out blank android
    text
    copied!<p>Hi I've look through all the stackoverflow and tried a few solutions,and I still cant solve my problem. I'm still fairly new to json parsing and android, any help would be greatly appreciated.</p> <p>this is my json url-<a href="http://vina.harvestcamasu.com/vina/xml/image.json" rel="nofollow">http://vina.harvestcamasu.com/vina/xml/image.json</a> and this is the code that I tried</p> <pre><code> json = jParser.getJSONFromUrl(url); JSONObject json = jParser.getJSONFromUrl(url); System.out.println("json is "+json); System.out.println("Length"+TAG_IMAGE .length()); for (int i = 0; i &lt; json.length(); i++) { try { String atObj = Integer.toString(i); System.out.println(atObj); JSONObject jObj = json.getJSONObject(atObj); System.out.println(jObj.getString("Name")); System.out.println(jObj.getString("PicURL")); System.out.println(jObj.getString("Caption")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } JSONArray iArray; try { iArray = json.getJSONArray(TAG_IMAGE); for (int i = 0; i &lt; iArray.length(); i++) { JSONObject m = iArray.getJSONObject(i); String Id = m.getString(TAG_ID); String Name = m.getString(TAG_NAME); String PicURL = m.getString(TAG_PICURL); String Date = m.getString(TAG_DATE); String Caption = m.getString(TAG_CAPTION); //create a new hashmap HashMap&lt;String, String&gt; map = new HashMap&lt;String, String&gt;(); //adding nodes into hashmap map.put(TAG_ID, Id); map.put(TAG_NAME, Name); map.put(TAG_PICURL, PicURL); map.put(TAG_DATE, Date); map.put(TAG_CAPTION, Caption); //adding hashlist into arraylist imagelist.add(map); images[i] = m.getString(TAG_PICURL); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } InputStream is1 = (InputStream) new URL(images[0]).getContent(); d1 = Drawable.createFromStream(is1, "src name"); InputStream is2 = (InputStream) new URL(images[1]).getContent(); d2 = Drawable.createFromStream(is2, "src name"); InputStream is3 = (InputStream) new URL(images[2]).getContent(); d3 = Drawable.createFromStream(is3, "src name"); InputStream is4 = (InputStream) new URL(images[3]).getContent(); d4 = Drawable.createFromStream(is4, "src name"); InputStream is5 = (InputStream) new URL(images[4]).getContent(); d5 = Drawable.createFromStream(is5, "srcname"); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return json; } </code></pre> <p>and the log keeps returning the error of </p> <pre><code> 12-04 10:12:02.892: W/System.err(28210): org.json.JSONException: No value for 0 12-04 10:12:02.892: W/System.err(28210): at org.json.JSONObject.get(JSONObject.java:354) 12-04 10:12:02.892: W/System.err(28210): at org.json.JSONObject.getJSONObject(JSONObject.java:569) 12-04 10:12:02.892: W/System.err(28210): at vinajson.img.MainActivity$1.doInBackground(MainActivity.java:82) 12-04 10:12:02.892: W/System.err(28210): at vinajson.img.MainActivity$1.doInBackground(MainActivity.java:1) 12-04 10:12:02.892: W/System.err(28210): at android.os.AsyncTask$2.call(AsyncTask.java:264) 12-04 10:12:02.892: W/System.err(28210): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-04 10:12:02.892: W/System.err(28210): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-04 10:12:02.900: W/System.err(28210): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 12-04 10:12:02.900: W/System.err(28210): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-04 10:12:02.900: W/System.err(28210): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-04 10:12:02.900: W/System.err(28210): at java.lang.Thread.run(Thread.java:856) 12-04 10:12:02.900: W/System.err(28210): org.json.JSONException: No value for Image 12-04 10:12:02.900: W/System.err(28210): at org.json.JSONObject.get(JSONObject.java:354) 12-04 10:12:02.900: W/System.err(28210): at org.json.JSONObject.getJSONArray(JSONObject.java:544) 12-04 10:12:02.900: W/System.err(28210): at vinajson.img.MainActivity$1.doInBackground(MainActivity.java:93) 12-04 10:12:02.900: W/System.err(28210): at vinajson.img.MainActivity$1.doInBackground(MainActivity.java:1) 12-04 10:12:02.900: W/System.err(28210): at android.os.AsyncTask$2.call(AsyncTask.java:264) 12-04 10:12:02.900: W/System.err(28210): at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) 12-04 10:12:02.900: W/System.err(28210): at java.util.concurrent.FutureTask.run(FutureTask.java:137) 12-04 10:12:02.900: W/System.err(28210): at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:208) 12-04 10:12:02.900: W/System.err(28210): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) 12-04 10:12:02.900: W/System.err(28210): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) 12-04 10:12:02.900: W/System.err(28210): at java.lang.Thread.run(Thread.java:856) 12-04 10:12:02.900: W/System.err(28210): java.net.MalformedURLException </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload