Fix the json representation of an agent.
6410
def _fix_json_agents(ag_obj):
    """"""
    if isinstance(ag_obj, str):
        logger.info("Fixing string agent: %s." % ag_obj)
        ret = {'name': ag_obj, 'db_refs': {'TEXT': ag_obj}}
    elif isinstance(ag_obj, list):
        # Recursive for complexes and similar.
        ret = [_fix_json_agents(ag) for ag in ag_obj]
    elif isinstance(ag_obj, dict) and 'TEXT' in ag_obj.keys():
        ret = deepcopy(ag_obj)
        text = ret.pop('TEXT')
        ret['db_refs']['TEXT'] = text
    else:
        ret = ag_obj
    return ret
236213
def save_json(object, handle, indent=2):
    """"""
    obj_json = json.dumps(object, indent=indent, cls=NumpyJSONEncoder)
    handle.write(obj_json)
765921
def spl_json(self):
        """"""
        _splj = {}
        _splj["type"] = self._type
        _splj["value"] = self._value
        return _splj
272383
def fix_additional_fields(data):
        """"""
        result = dict()
        for key, value in data.items():
            if isinstance(value, dict):
                result.update(KserSpan.to_flat_dict(key, value))
            else:
                result[key] = value
        return result
1306208
def reduce_json(data):
    """"""
    return reduce(lambda x, y: int(x) + int(y), data.values())
536553
def _responsify(api_spec, error, status):
    """"""
    result_json = api_spec.model_to_json(error)
    r = jsonify(result_json)
    r.status_code = status
    return r
160385
function decode ( value ) {
	let resolvedValue = {};
	try {
		resolvedValue = JSON.parse(value.getValue());
	} catch ( e ) {
		resolvedValue = null;
	}
	return setJsonValueToSassValue(resolvedValue);
}
627360
def wrap_json(cls, json):
        
        if json is None:
            return None
        channel = Channel.wrap_json(json.get('channel'))
        s = Stream(game=json.get('game'),
                   channel=channel,
                   twitchid=json.get('_id'),
                   viewers=json.get('viewers'),
                   preview=json.get('preview'))
        return s
459499
def json_format(out, graph):
    """"""
    steps = {}
    for step, deps in each_step(graph):
        steps[step.name] = {}
        steps[step.name]["deps"] = [dep.name for dep in deps]

    json.dump({"steps": steps}, out, indent=4)
    out.write("\n")
1094648
def fix(source_key, rownum, line, source, sample_only_filter, sample_size):
    
    value = json2value(line)

    if rownum == 0:
        if len(line) > MAX_RECORD_LENGTH:
            _shorten(source_key, value, source)
        value = _fix(value)
        if sample_only_filter and Random.int(int(1.0/coalesce(sample_size, 0.01))) != 0 and jx.filter([value], sample_only_filter):
            # INDEX etl.id==0, BUT NO MORE
            if value.etl.id != 0:
                Log.error("Expecting etl.id==0")
            row = {"value": value}
            return row, True
    elif len(line) > MAX_RECORD_LENGTH:
        _shorten(source_key, value, source)
        value = _fix(value)
    elif '"resource_usage":' in line:
        value = _fix(value)

    row = {"value": value}
    return row, False
437898
function formatjson(pis) {
	return pis.map(function(pi) {
		var newpi = {};
		newpi[pi.tag] = pi.att;
		return newpi;
	});
}
1125816
def to_json_format(conf):
    ''''''
    if 'fmode' in conf:
        conf['fmode'] = oct(conf['fmode'])[-3:]
    if 'dmode' in conf:
        conf['dmode'] = oct(conf['dmode'])[-3:]
732242
def action_as_json(action)
      json = {}
      json[:default_title] = action.title if action.title
      json[:default_icon] = action.icon if action.icon
      json[:default_popup] = action.popup if action.popup
      json
    end
65471
def agent_update(self, agent_id, data, **kwargs):
        ""
        api_path = "/api/v2/agents/{agent_id}"
        api_path = api_path.format(agent_id=agent_id)
        return self.call(api_path, method="PUT", data=data, **kwargs)
924189
def toJson(self, data=None, pretty=False):
        """"""
        if data==None: data = self.attrs
        data = self.flatten(data) # don't send objects as str in json
        #if pretty:
        ret = json.dumps(data, indent=4, sort_keys=True)
        #self.inflate() # restore objects from json str data
        return ret
341387
def as_json(self):
        # type: () -> dict
        """"""
        self._config['applyCss'] = self.applyCss
        self._json['config'] = self._config
        return self._json
642973
def read_json_breakdown(cls, fname):
        """"""
        if not os.path.exists(fname):
            raise RuntimeError

        with open(fname, 'r') as data_file:
            return cls.fixup_from_json(data_file.read())