code: def dump(obj, path, **kw):
      
      open_kw = {'mode': 'w'}
      if PY3:  # pragma: no cover
          open_kw['encoding'] = 'utf-8'
  
      # avoid indented lines ending with ", " on PY2
      if kw.get('indent') and kw.get('separators') is None:
          kw['separators'] = (',', ': ')
  
      with open(str(path), **open_kw) as fp:
          return json.dump(obj, fp, **kw)
docs: Python 2 + 3 compatible version of json.dump.
  
      :param obj: The object to be dumped.
      :param path: The path of the JSON file to be written.
      :param kw: Keyword parameters are passed to json.dump