Skip to content

Instantly share code, notes, and snippets.

@schlameel
Created September 5, 2016 23:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schlameel/e5fb40504d0cd608d796b0d43cab82ad to your computer and use it in GitHub Desktop.
Save schlameel/e5fb40504d0cd608d796b0d43cab82ad to your computer and use it in GitHub Desktop.
A simple example of the usage of JsonCls available at https://github.com/schlameel/JsonCls
class Character(JsonCls):
name = Member()
actor = Member()
film = Member()
json_str = "{ 'name' : 'Dead Collector',
'actor' : 'Eric Idle',
'film' : 'Monty Python and the Holy Grail' }
character = Character().json(json_str)
print character.json()
# Prints:
# {'name': 'Dead Collector', 'actor': 'Eric Idle', 'film': 'Monty Python and the Holy Grail'}
print character.json(indent=2)
# Prints:
# {
# 'name': 'Dead Collector',
# 'actor': 'Eric Idle',
# 'film': 'Monty Python and the Holy Grail'
#}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment