Note that there are some explanatory texts on larger screens.

plurals
  1. POCreate a parsable JSON file for android application
    text
    copied!<p>I'm trying to get a list of images in a json file I have on my webserver with my android application. But they are not being read, I must have made some mistake, probably in my json file. </p> <p>I'm trying to create a .Json file my application can read, one of my experimental JSON files is listed below, but it's not working.</p> <p>Since I'm not very experienced with Json I was wondering if somebody else might know how to create a JSON file my application can parse.</p> <p>My experimental json file:</p> <pre><code>{ "Wallpaper": [ { "id": "1", "title": "Clouds", "thumburl": "http://url.com/images/Pages/Apps/apps.png", "previewurl": "http://url.com/images/Pages/Apps/apps.png", "url": "http://url.com/images/Pages/Apps/apps.png", "text": "Sky" } ] } </code></pre> <p>And my code:</p> <pre><code> import someimportsandotherstuff import de.dan_nrw.android.scroid.Wallpaper; public final class JsonWallpaperParser implements IWallpaperParser { /** * Creates a new instance of JsonWallpaperParser. */ JsonWallpaperParser() { super(); } /* (non-Javadoc) * @see de.dan_nrw.boobleftboobright.IWallpaperParser#parse(java.lang.String) */ @Override public List&lt;Wallpaper&gt; parse(String data) throws ParseException { try { JSONArray array = new JSONArray(data); List&lt;Wallpaper&gt; wallpapers = new ArrayList&lt;Wallpaper&gt;(); for (int i = 0; i &lt; array.length(); i++) { JSONObject jsonWallpaper = array.getJSONObject(i); wallpapers.add(new Wallpaper(jsonWallpaper.getString("id"), jsonWallpaper.getString("title"), URI.create(jsonWallpaper.getString("thumburl")), URI.create(jsonWallpaper.getString("previewurl")), URI.create(jsonWallpaper.getString("url")), jsonWallpaper.getString("text"))); } return wallpapers; } catch (JSONException ex) { throw new ParseException(ex.getMessage(), 0); } } } </code></pre> <p>Any help is appreciated!</p>
 

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