Python object to/from JSON string

import json

user = {
    "name": "Test",
    "_id": "1234567890",
    "address": {
        "street": "De Anza",
        "city": "San Jose"
    }
}


json_from_user = json.JSONEncoder().encode(user)

print json_from_user

user_from_json = json.JSONDecoder().decode(json_from_user)

print user_from_json
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a comment