code: def write_json(dictionary, filename):
      
      with open(filename, 'w') as data_file:
          json.dump(dictionary, data_file, indent=4, sort_keys=True)
      print('--> Wrote ' + os.path.basename(filename))
docs: Write dictionary to JSON