My project is currently receiving a JSON message in python which I need to get bits of information out of. For the purposes of this, let\'s set it to some simple JSON in a s
For URL or file, use json.load()
. For string with .json content, use json.loads()
.
#! /usr/bin/python
import json
# from pprint import pprint
json_file = 'my_cube.json'
cube = '1'
with open(json_file) as json_data:
data = json.load(json_data)
# pprint(data)
print "Dimension: ", data['cubes'][cube]['dim']
print "Measures: ", data['cubes'][cube]['meas']