ValueError("No JSON object could be decoded") Python googlemaps
Question: I am using Google app engine (v1.9.24) with flask (v0.10.1) and python
(v2.7.5).

I'm trying to get the googlemaps (v2.2) API to work with my app.

I know the JSON returned is badly formatted but I don't why.

My code is below:

    
    
    import googlemaps
    gmaps = googlemaps.Client(key='API_KEY')
    geocode_result = gmaps.geocode('6b, oko awo, victoria island, lagos')
    return geocode_result
    

This works perfectly, but returns a badly formatted JSON string (I confirmed
this by running the same code on my local machine).

I used [JSON validator](http://jsonlint.com) to validate the JSON it returned.
And because of the badly fomatted JSON my flask app crashes and gives me a
ValueError. I don't know a way around this and I'd appreciate any help.


Answer: The problem is not with the JSON. Actually,

    
    
    gmaps.geocode('6b, oko awo, victoria island, lagos')
    

doesn't return JSON at all, it returns a list that holds the value of "result"
as documented in [the google
docs](https://developers.google.com/maps/documentation/geocoding/intro), as
you can see [here](https://github.com/googlemaps/google-maps-services-
python/blob/master/googlemaps/geocoding.py) in the source code for googlemaps
library.

What is actually returned is a list object filled with data. All the string
values inside this list are unicode strings. That means they look like
`u'hello'` instead of plain `"hello"` (note the double quotes) that
json.loads() expects (I assume that is how you are trying to load the JSON).

This probably means that the problem you're trying to solve a non existing
problem. You don't have to load the JSON, because it already is a python list
object.

You can confirm by doing

    
    
    json.loads(json.dumps(geocode_result))
    

it works fine, meaning there is no problem with the JSON structure.

