code: def json_to_file(data, filename, pretty=False):
      '''Dump JSON data to a file'''
      kwargs = dict(indent=4) if pretty else {}
      dirname = os.path.dirname(filename)
      if not os.path.exists(dirname):
          os.makedirs(dirname)
      dump = json.dumps(api.__schema__, **kwargs)
      with open(filename, 'wb') as f:
          f.write(dump.encode('utf-8')f json_to_file(data, filename, pretty=False):
      '''Dump JSON data to a file'''
      kwargs = dict(indent=4) if pretty else {}
      dirname = os.path.dirname(filename)
      if not os.path.exists(dirname):
          os.makedirs(dirname)
      dump = json.dumps(api.__schema__, **kwargs)
      with open(filename, 'wb') as f:
          f.write(dump.encode('utf-8'))
docs: Dump JSON data to a file