Here is the relevant part of my json file:
"categories": [
[
"Belgian Restaurant",
"belgian"
],
[
"Brasserie",
"brasseries"
]
],
What I want to do is get information from the second JSONArray(say, for example, "brasseries").
The following code worked to extract information from the first array:
JSONArray categories = jsonObject.getJSONArray("categories");
restaurant.setCat1(categories.getJSONArray(0).getString(1));
The result of this was “Belgian”, as expected, but then I tried the same for the second array:
restaurant.setCat2(categories.getJSONArray(1).getString(1));
and what Index 1 out of range [0..1)JSONException chose
I do not get it, since indexes 0 and 1 explicitly exist in the file ... Why does 0 work, not 1?
source
share