I'm trying to parse some information but I get some errors. This is part of my code:
public static ArrayList<Advertiser> negociosCiudad(String ciudad){
ArrayList<Advertiser> result = new ArrayList<Advertiser>();
JSONParser jp = new JSONParser();
JSONArray jArray = jp.getJSONFromUrl(URL + "searchByCity/" + ciudad);
try {
for (int i = 0; i < jArray.length(); i++) {
Advertiser a = new Advertiser();
JSONObject o = jArray.getJSONObject(i);
a.setDireccion(o.getString(TAG_ADDRESS));
a.setId(o.getString(TAG_ADVERTISER_ID));
a.setCiudad(o.getString(TAG_CITY));
...
}
}
This is what I'm receiving:
["Hello","Good Bye","Errors","Everywhere","Help", ...]
And this is the error I'm getting:
org.json.JSONException: Value Hello at 0 of type java.lang.String cannot be converted to JSONArray
I haven't figured out how to do this correctly, but I believe it's something simple. I realized that I'm not using JSON arrays, but I don't know what to do.
I'll be editing this post with the things I'm trying to do to fix it.
Thank you in advance.
EDIT
I had a mistake and put a different response, let me get the real one since ["Hello","Good Bye","Errors","Everywhere","Help", ...] is from another query –
JSONArray, and containsStrings{"TAG_ADDRESS":"1234 Some Rd", "TAG_ADVERTISER_ID":"546", "TAG_CITY":"City"}