my problem is that my android app does not parse the following JSON
data. If I use other json
sources it parses OK. I've validated the json bellow and there were no problems. It doesn't throw any error. I can't understand why. Could it be because of the date being first?
Json data looks like this:
{
"2015-05-23 18:48:58": {
"Titlu": "kgjsdfklgjfdgjsdlgjdgjfd",
"PozaPrincipala": "27602",
"Descriere": "fkdsgjslkfdglkgfdsgfdklnm",
"CMSdate": "2015-05-23 18:48:58",
"url": "http://fsdgdgfdggsdfgfgfdg",
"thumb": "http://dasidsaionofafnoinfasnisa"
},
"2015-05-21 20:17:36": {
"Titlu": "jhsdkgjshfgsjdfkhgsf",
"PozaPrincipala": "27592",
"Descriere": "kldsjgfhgdhgfhgsdfhifhgisf",
"CMSdate": "2015-05-21 20:17:36",
"url": "http://gsfdgfsdgsfdgfdgfdg",
"thumb": "http://dvsddggsfngfsgsfn"
}
}
And my code for parsing:
private static final String url = "http://xxx.ro/xxx";
// Creating volley request obj
JsonArrayRequest movieReq = new JsonArrayRequest(url,
new Response.Listener<JSONArray>() {
public void onResponse(JSONArray response) {
Log.d(TAG, response.toString());
hidePDialog();
Log.d(TAG, response.toString());
// Parsing json
for (int i = 0; i < response.length(); i++) {
try {
JSONObject obj = response.getJSONObject(i);
Movie movie = new Movie();
movie.setTitle(obj.getString("Titlu"));
movie.setThumbnailUrl(obj.getString("thumb"));
movie.setLink(obj.getString("url"));
// adding movie to movies array
movieList.add(movie);
} catch (JSONException e) {
e.printStackTrace();
}
}
// notifying list adapter about data changes
// so that it renders the list view with updated data
adapter.notifyDataSetChanged();
}
}, new Response.ErrorListener() {
public void onErrorResponse(VolleyError error) {
VolleyLog.d(TAG, "Error: " + error.getMessage());
hidePDialog();
}
});