Creates/Modifies file and saves python object as JSON

    :param filename:
    :param blob:
    :param force_write:
    :param debug:

    :return:
777613
def save_blob_as_json(filename, blob, force_write, debug):
    
    try:
        if prompt_4_overwrite(filename, force_write):
            with open(filename, 'wt') as f:
                print('%s' % json.dumps(blob, indent=4 if debug else None, separators=(',', ': '), sort_keys=True, cls=CustomJSONEncoder), file=f)
    except Exception as e:
        printException(e)
        pass
1076738
def _write_json(filepath, data, kwargs):
    """"""
    with io_stl.open(filepath, 'w', encoding='utf8') as outfile:
        if 'indent' not in kwargs:
            kwargs['indent'] = 4
        if 'sort_keys' not in kwargs:
            kwargs['sort_keys'] = True
        if 'separators' not in kwargs:
            kwargs['separators'] = (',', ': ')
        if 'ensure_ascii' not in kwargs:
            kwargs['ensure_ascii'] = False
        str_ = json.dumps(data, **kwargs)
        outfile.write(to_unicode(str_))
    return data
444183
def _create_blob(self):
        """"""
        blob = None
        for line in self.blob_file:
            line = try_decode_string(line)
            line = line.strip()
            if line == '':
                self.log.info("Ignoring empty line...")
                continue
            if line.startswith('end_event:') and blob:
                blob['raw_header'] = self.raw_header
                return blob
            try:
                tag, values = line.split(':')
            except ValueError:
                self.log.warning("Ignoring corrupt line: {}".format(line))
                continue
            try:
                values = tuple(split(values.strip(), callback=float))
            except ValueError:
                self.log.info("Empty value: {}".format(values))
            if line.startswith('start_event:'):
                blob = Blob()
                blob[tag] = tuple(int(v) for v in values)
                continue
            if tag not in blob:
                blob[tag] = []
            blob[tag].append(values)
872827
def save(self, fname):
        
        with open(fname, 'wb') as f:
            json.dump(self, f)
205739
def write_json_to_file(self, net_type, filename, indent='no-indent'):
    '''
    
    '''
    export_data.write_json_to_file(self, net_type, filename, indent)
289997
def _create_json(self):
        
        data_json = {
            "rclass": "local",
            "key": self.name,
            "description": self.description,
            "packageType": self.packageType,
            "notes": "",
            "includesPattern": "**/*",
            "excludesPattern": "",
            "repoLayoutRef": self.repoLayoutRef,
            "dockerApiVersion": self.dockerApiVersion,
            "checksumPolicyType": "client-checksums",
            "handleReleases": True,
            "handleSnapshots": True,
            "maxUniqueSnapshots": 0,
            "snapshotVersionBehavior": "unique",
            "suppressPomConsistencyChecks": True,
            "blackedOut": False,
            "propertySets": [],
            "archiveBrowsingEnabled": self.archiveBrowsingEnabled,
            "yumRootDepth": 0,
        }
        return data_json
1205056
def save_json(filename: str, config: Union[List, Dict]):
    
    try:
        data = json.dumps(config, sort_keys=True, indent=4)
        with open(filename, 'w', encoding='utf-8') as fdesc:
            fdesc.write(data)
            return True
    except TypeError as error:
        _LOGGER.exception('Failed to serialize to JSON: %s',
                          filename)
        raise PytradfriError(error)
    except OSError as error:
        _LOGGER.exception('Saving JSON file failed: %s',
                          filename)
        raise PytradfriError(error)
362635
def write_json(template, file_name='../dxf.json.template'):
    
    with open(file_name, 'w') as f:
        json.dump(template, f, indent=4)
1288162
def generate_fileattr_metadata(local_path, metadata):
    # type: (blobxfer.models.upload.LocalPath, dict) -> dict
    
    if blobxfer.util.on_windows():
        global _FILEATTR_WARNED_ON_WINDOWS
        if not _FILEATTR_WARNED_ON_WINDOWS:
            _FILEATTR_WARNED_ON_WINDOWS = True
            logger.warning(
                'file attributes store/restore on Windows is not '
                'supported yet')
        return None
    else:
        md = {
            _JSON_KEY_FILE_ATTRIBUTES: {
                _JSON_KEY_FILE_ATTRIBUTES_POSIX: {
                    _JSON_KEY_FILE_ATTRIBUTES_MODE: local_path.mode,
                    _JSON_KEY_FILE_ATTRIBUTES_UID: local_path.uid,
                    _JSON_KEY_FILE_ATTRIBUTES_GID: local_path.gid,
                }
            }
        }
        return blobxfer.util.merge_dict(metadata, md)
223261
def save(markov, fname, args):
    
    if isinstance(markov.storage, JsonStorage):
        if fname is None:
            markov.save(sys.stdout)
        else:
            if fname.endswith('.bz2'):
                open_ = bz2.open
            else:
                open_ = open
            if args.progress:
                print('Saving JSON data...')
            with open_(fname, 'wt') as fp:
                markov.save(fp)
    else:
        markov.save()
1314264
def save_json(obj, filename, **kwargs):
    

    with open(filename, 'w', encoding='utf-8') as f:
        json.dump(obj, f, **kwargs)
495224
function writeJSON(filename, obj) {

    return new Promise(function (resolve, reject) {

      if (!Object.is(obj)) resolve(new Error('writeJSON requires the second argument to be an object'));

      _fs2['default'].writeFile(filename, JSON.stringify(obj, null, 2) + '\n', function (err) {
        if (err) reject(err);
        resolve(obj);
      });
    });
  }
581089
def save_data(self, filename):
        
        with zopen(filename, "wt") as f:
            json.dump(list(self._data), f, cls=MontyEncoder)
354173
def create_blob(self, content, encoding):
        
        sha = ''
        if encoding in ('base64', 'utf-8'):
            url = self._build_url('git', 'blobs', base_url=self._api)
            data = {'content': content, 'encoding': encoding}
            json = self._json(self._post(url, data=data), 201)
            if json:
                sha = json.get('sha')
        return sha
818689
def add_fileobj(self, fname, fcontent):
        
        tar_info = tarfile.TarInfo(fname)
        if isinstance(fcontent, io.BytesIO):
            tar_info.size = len(fcontent.getvalue())
        elif isinstance(fcontent, io.StringIO):
            tar_info.size = len(fcontent.getvalue())
            fcontent = io.BytesIO(fcontent.getvalue().encode("utf8"))
        else:
            if hasattr(fcontent, "readable"):
                fcontent = fcontent
            tar_info.size = len(fcontent)
            if isinstance(fcontent, str):
                fcontent = fcontent.encode("utf8")
            fcontent = io.BytesIO(fcontent)
        self._ios_to_add[tar_info] = fcontent
549998
def to_json(self):
    

    return {self.BLOB_KEY_PARAM: self._blob_key,
            self.START_FILE_INDEX_PARAM: self._start_file_index,
            self.END_FILE_INDEX_PARAM: self._end_file_index,
            self.OFFSET_PARAM: self._next_offset()}
151676
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))