Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to convert a string that contain array element into JSONArray
    primarykey
    data
    text
    <p>I've been experiencing some problems for quite some time trying to load a string that contains an array into a JSONArray. i get the following string from a web-service which contains the movies array: {"total":3,"movies":[],"links":{......}"}</p> <p>i'm looking to convert this array into a JASONArray and show it using a list view. i'm using the following code and it not working....</p> <pre><code> protected void onPostExecute(String result) { Log.d(TAG, "result: " + result); if (result==null || result.length()==0){ // no result: return; } //clear the list moviesList.clear(); try { //turn the result into a JSON object Log.d(TAG, "create responseObject: "); JSONObject responseObject = new JSONObject(result); Log.d(TAG, responseObject.toString()); // get the JSON array named "movies" JSONArray resultsArray = responseObject.getJSONArray("movies"); Log.d(TAG, "JSONArray lenght: " + resultsArray.length()); // Iterate over the JSON array: for (int i = 0; i &lt; resultsArray.length(); i++) { // the JSON object in position i JSONObject movieObject = resultsArray.getJSONObject(i); Log.d(TAG, "movieObject (from array) : " + movieObject.toString()); // get the primitive values in the object String title = movieObject.getString("title"); String details = movieObject.getString("synopsis"); //put into the list: Movie movie = new Movie(title, details, null,null); //public Movie(String title, String details, String urlnet, String urldevice) { moviesList.add(movie); } } catch (JSONException e) { e.printStackTrace(); } //refresh listView: adapter.notifyDataSetChanged(); } </code></pre> <p>I was hoping a post here would help me solve the problem. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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