Scott Scott - 2 years ago 110
JSON Question

how to print json data

I have following json file and python code and i need output example...

json file

{"b": [{"1": "add"},{"2": "act"}],
"p": [{"add": "added"},{"act": "acted"}],
"pp": [{"add": "added"},{"act": "acted"}],
"s": [{"add": "adds"},{"act": "acts"}],
"ing": [{"add": "adding"},{"act": "acting"}]}


import json
data = json.load(open('jsonfile.json'))
#print data

out put example

>> b
>> p
>> pp
>> s
>> ing

any ideas how to do that?

Answer Source

This doesn't have anything to do with JSON. You have a dictionary, and you want to print the keys, which you can do with data.keys().

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download