import json #code works! #x = json.loads('{"name":"hello","age":["25","26"]}') #print x['name'] #print x['age'] #print x['age'][0] #code works! #var = json.loads('[{"http:\/\/example.com\/index.html":[{"method":"GET/POST","params":[{"key":"param1","value":"\'or 1 = 1\'"}]}]}]') #for attribute, value in var[0].iteritems(): # print "attribute : " + attribute # example usage #print var[0] jsonInput = json.loads('{ "page1":{"payload":["A","B"],"param":[{"name":"X1","type":"X1"},{"name":"X2","type":"X2"}]}, "page2":{"payload":["C","D"],"param":[{"name":"X3","type":"X3"},{"name":"X4","type":"X4"}]}}') for pageUrl,pageObj in jsonInput.iteritems(): print "attribute : " + pageUrl for payloads in pageObj['payload']: print "PayLoad : "+payloads for params in pageObj['param']: print "Name : "+params['name'] + " Type : "+params['type']
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question