python access json object code example

Example 1: python read json file

import json

with open('path_to_file/person.json') as f:
  data = json.load(f)

print(data)

Example 2: how to get specific data from json using python

with open('distros.json', 'r') as f:
    distros_dict = json.load(f)

for distro in distros_dict:
    print(distro['Name'])

Example 3: access json python

# Set common labels
ax.set_xlabel('common xlabel')
ax.set_ylabel('common ylabel')

ax1.set_title('ax1 title')
ax2.set_title('ax2 title')

plt.savefig('common_labels.png', dpi=300)