Get a JSON object in python
Question: Usually my webservice built with Bottle return JSON files, which works fine.
But, I've an exception that need to call a local function.

Here is what I tried to do:

    
    
    import json
    def getData():
        return json.dumps({'data': someData })
    
    def function():
        try:
            # Fail
        except:
            print getData()
            print type(getData())
            json.load(getData())
    

So it prints:

    
    
    {"data": "myData"}
    <type 'str'>
    [...]
    AttributeError: 'str' object has no attribute 'read'
    

So `json.dumps` gives me a string. How can I use it as JSON ?


Answer: `json.load` loads JSON from a file object.

`json.loads` loads from a string. This is what you want.

