JSONObject["locationInfo"] not a string JSONObject["locationInfo"] not a string json json

JSONObject["locationInfo"] not a string


You need to check whether your "locationInfo" string is null:

if (json.isNull("locationInfo")){  mapLoc = "";} else {  mapLoc = json.getString("locationInfo");}


In json location is another json object.

so you would use:

json.getJSONObject("locationInfo")

furthermore for latitude then:

json.getJSONObject("locationInfo").getString("latitude")


I think the problem is that in fact "locationInfo" is not a string but a JSONObject.

Take a look at documentation

You could try to get

org.json.JSONObject jsonlocationInfo = json.getJSONObject("locationInfo");