I'm trying to read two json arrays from same request
JSON FILE:
{
"items": [
{
"title": "welcoem home",
"author": "Charles Dickens"
},
{
"title": "Harry Potter",
"author": "J rowling"
}]
}
{
"items1": [
{
"title": "welcoem home",
"author": "Charles Dickens"
},
{
"title": "Harry Potter",
"author": "J rowling"
}]
}
and the code I use to read is:
//Convert JSON to String and gets our app version
private String getJSON(String JSON_STRING){
try {
//Objects
jsonObject=new JSONObject(JSON_STRING);
jsonArray=jsonObject.getJSONArray("items");
//Variables
int count=0;
String tempTitle, temAuthor;
while (count<jsonArray.length()){
//Reads Row by Row
JSONObject JO= jsonArray.getJSONObject(count);
tempTitle= JO.getString("title");
temAuthor= JO.getString("author");
//If our App found
if (Constants.Title.equals(tempTitle)){
return temAuthor;
}
count++;
}
} catch (JSONException e) {
e.printStackTrace();
}
return "Not Found!";
}
but when I call to read the second table like items1 it says no table found? I tried to add a (,) between tables but same, I'm newbie in both php and android so its hard for me to change the code, so it is any easy way for me, I mean any way to change less code to make it work, or I have to change my android method completely ?
jsonformat is wrong. Correct it first