Save loss in json format
320632
def save(self, path):
    
    json.dump(dict(loss=self.__class__.__name__,
                   params=self.hparams),
              open(os.path.join(path, 'loss.json'), 'wb'))
1049797
def save
      json = MultiJson.encode(attributes)
      File.open(file, 'w') {|f| f.write(json) }
    end
809186
function toJSON( err ) {
	var keys;
	var out;
	var i;
	if ( !( err instanceof Error ) ) {
		throw new TypeError( 'invalid input argument. Must provide an error object. Value: `' + err + '`.' );
	}
	out = {};

	// Guaranteed properties:
	out.type = typeName( err );
	out.message = err.message;

	// Possible general error properties...
	if ( err.name ) {
		out.name = err.name;
	}
	if ( err.stack ) {
		out.stack = err.stack;
	}
	// Possible Node.js (system error) properties...
	if ( err.code ) {
		out.code = err.code;
	}
	if ( err.errno ) {
		out.errno = err.errno;
	}
	if ( err.syscall ) {
		out.syscall = err.syscall;
	}
	// Any enumerable properties...
	keys = getKeys( err );
	for ( i = 0; i < keys.length; i++ ) {
		out[ keys[i] ] = copy( err[ keys[i] ] );
	}
	return out;
}
1143972
def savejson(filename, datadict):
    
    for key, value in datadict.items():
        if type(value) == np.ndarray:
            datadict[key] = value.tolist()
        if type(value) == dict:
            for key2, value2 in value.items():
                if type(value2) == np.ndarray:
                    datadict[key][key2] = value2.tolist()
    with open(filename, "w") as f:
        f.write(json.dumps(datadict, indent=4))
552200
def dumps(self, blob):
        

        return json.dumps(
            blob, indent=self.indent, sort_keys=True,
            separators=self.separators,
        )
1118554
def dump(obj, fp, **user_kwargs):
    
    return json.dump(obj, fp, **_encoder_kwargs(user_kwargs))
1161867
def dump_json(model, batch_len=200000, use_natural_keys=True, verbosity=1):
    
    model = get_model(model)

    N = model.objects.count()

    if verbosity > 0:
        widgets = [pb.Counter(), '/%d rows: ' % (N,), pb.Percentage(), ' ', pb.RotatingMarker(), ' ', pb.Bar(),' ', pb.ETA()]
        i, pbar = 0, pb.ProgressBar(widgets=widgets, maxval=N).start()

    JSONSerializer = serializers.get_serializer("json")
    jser = JSONSerializer()

    if verbosity > 0:
        pbar.update(0)
    for i, partial_qs in enumerate(util.generate_slices(model.objects.all(), batch_len=batch_len)):
        with open(model._meta.app_label.lower() + '--' + model._meta.object_name.lower() + '--%04d.json' % i, 'w') as fpout:
            if verbosity > 0:
                pbar.update(i*batch_len)
            jser.serialize(partial_qs, indent=1, stream=fpout, use_natural_keys=use_natural_keys)
    if verbosity > 0:
        pbar.finish()
378171
def as_json(self, ensure_ascii=False):
        """"""
        return json.dumps(self.as_dict, ensure_ascii=ensure_ascii)
661643
def save_to_json(self):
        """"""
        requestvalues = {
            'DatasetId': self.dataset,
            'Name': self.name,
            'Description': self.description,
            'Source': self.source,
            'PubDate': self.publication_date,
            'AccessedOn': self.accessed_on,
            'Url': self.dataset_ref,
            'UploadFormatType': self.upload_format_type,
            'Columns': self.columns,
            'FileProperty': self.file_property.__dict__,
            'FlatDSUpdateOptions': self.flat_ds_update_options,
            'Public': self.public
        }
        return json.dumps(requestvalues)
581089
def save_data(self, filename):
        
        with zopen(filename, "wt") as f:
            json.dump(list(self._data), f, cls=MontyEncoder)
269836
def to_json(cls, config, compact=False, indent=2, level=0):
        
        lines = ""
        if isinstance(config, ConfigTree):
            if len(config) == 0:
                lines += '{}'
            else:
                lines += '{\n'
                bet_lines = []
                for key, item in config.items():
                    bet_lines.append('{indent}"{key}": {value}'.format(
                        indent=''.rjust((level + 1) * indent, ' '),
                        key=key.strip('"'),  # for dotted keys enclosed with "" to not be interpreted as nested key
                        value=cls.to_json(item, compact, indent, level + 1))
                    )
                lines += ',\n'.join(bet_lines)
                lines += '\n{indent}}}'.format(indent=''.rjust(level * indent, ' '))
        elif isinstance(config, list):
            if len(config) == 0:
                lines += '[]'
            else:
                lines += '[\n'
                bet_lines = []
                for item in config:
                    bet_lines.append('{indent}{value}'.format(
                        indent=''.rjust((level + 1) * indent, ' '),
                        value=cls.to_json(item, compact, indent, level + 1))
                    )
                lines += ',\n'.join(bet_lines)
                lines += '\n{indent}]'.format(indent=''.rjust(level * indent, ' '))
        elif isinstance(config, basestring):
            lines = json.dumps(config)
        elif config is None or isinstance(config, NoneValue):
            lines = 'null'
        elif config is True:
            lines = 'true'
        elif config is False:
            lines = 'false'
        else:
            lines = str(config)
        return lines
343447
def save(self, name, data, location='local', kind='json'):
        """"""
        file_ext = '.json' if kind == 'json' else '.pkl'
        path = self._get_path(name, location, file_ext=file_ext)
        _ensure_dir_exists(op.dirname(path))
        logger.debug("Save data to `%s`.", path)
        if kind == 'json':
            _save_json(path, data)
        else:
            _save_pickle(path, data)
348957
def to_output(self, value):
        """"""
        return json.loads(resolwe_runtime_utils.save(self.name, str(value)))
1257229
def save_json(self, jsonfn=None, pretty=True):
        
        if jsonfn is None:
            jsonfn = os.path.join(os.getcwd(), 'units.json')
        #
        jsondump = None
        sort_keys = False
        indent = 0
        if pretty:
            sort_keys = True
            indent = 4
        jsondump = json.dumps(self.units, sort_keys=sort_keys, indent=indent)
        #
        with open(jsonfn, 'w') as f:
            f.write(jsondump)
            return True
        return False
993324
def formatfundbjson(fundbjson):
        """"""
        result = {}
        for row in fundbjson["rows"]:
            cell = row["cell"]
            fundb_id = cell["fundb_id"]
            result[fundb_id] = cell
        return result
444362
def _record_from_json(value, field):
    """"""
    if _not_null(value, field):
        record = {}
        record_iter = zip(field.fields, value["f"])
        for subfield, cell in record_iter:
            converter = _CELLDATA_FROM_JSON[subfield.field_type]
            if subfield.mode == "REPEATED":
                value = [converter(item["v"], subfield) for item in cell["v"]]
            else:
                value = converter(cell["v"], subfield)
            record[subfield.name] = value
        return record
937550
public static void writeJsonToFile(String filename,
      List<SemanticParserExampleLoss> losses, List<Map<String, Object>> annotations) {
    Preconditions.checkArgument(annotations.size() == losses.size());
    List<String> lines = Lists.newArrayList();
    for (int i = 0; i < losses.size(); i++) {
      lines.add(losses.get(i).toJson(annotations.get(i)));
    }
    IoUtils.writeLines(filename, lines);
  }