Created
September 2, 2013 19:15
-
-
Save bodiam/6416328 to your computer and use it in GitHub Desktop.
Simple Python object to JSON mapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
class Light: | |
def __init__(self, id, name): | |
self.id = id | |
self.name = name | |
lights = [Light("1", "bedroom"),Light("2","kitchen")] | |
response = json.dumps([p.__dict__ for p in lights]) | |
print response |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment