Skip to content

Instantly share code, notes, and snippets.

@chaosx
Created January 21, 2019 03:06
Show Gist options
  • Select an option

  • Save chaosx/e03e0c4bb4edc6357532462830d4721d to your computer and use it in GitHub Desktop.

Select an option

Save chaosx/e03e0c4bb4edc6357532462830d4721d to your computer and use it in GitHub Desktop.
# author: Arpegius
# link: https://stackoverflow.com/users/142039/arpegius
import json
class JSONObject:
def __init__( self, dict ):
vars(self).update( dict )
#this is valid json string
data='{"channel":{"lastBuild":"2013-11-12", "component":["test1", "test2"]}}'
jsonobject = json.loads( data, object_hook= JSONObject)
print( jsonobject.channel.component[0] )
print( jsonobject.channel.lastBuild )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment