Helper function to stream content as an array of JSON values.
496543
def stream_array(self, generator):
        ''''''
        def chunkify(generator):
            log.debug('Data Stream STARTED')
            yield '['.encode()
            # In order to have commas only after the first value, we take the
            # first value of the generator manually
            try:
                yield jsonify(next(generator)).encode()
            except StopIteration:
                pass
            while True:
                try:
                    bit = next(generator)
                except StopIteration:
                    yield ']'.encode()
                    break
                else:
                    yield ',\n'.encode()
                    yield jsonify(bit).encode()
            log.debug('Data Stream ENDED')
        return chunkify(generator)
1083134
def loadjson(filename, asnparrays=False):
    
    with open(filename) as f:
        data = json.load(f)
    if asnparrays:
        for key, value in data.items():
            if type(value) is list:
                data[key] = np.asarray(value)
            if type(value) is dict:
                for key2, value2 in value.items():
                    if type(value2) is list:
                        data[key][key2] = np.asarray(value2)
    return data
116185
def __load_json(self, stream):
        

        import json

        try:
            return json.loads(stream)
        except ValueError as e:
            cause = "invalid json format. %s" % str(e)
        raise InvalidFormatError(cause=cause)
173664
def load_json(filename):
    """"""
    try:
        if PY2:
            args = 'rb'
        else:
            args = 'r'
        with open(filename, args) as fid:
            data = json.load(fid)
        return data, None
    except Exception as err:
        return None, str(err)
634582
def ToArray(value):
        
        ms = StreamManager.GetStream()
        writer = BinaryWriter(ms)

        value.Serialize(writer)

        retVal = ms.ToArray()
        StreamManager.ReleaseStream(ms)

        return retVal
1081343
def get_json(self, path, watch=None):
        """"""
        data, _ = self.get(path, watch)
        return load_json(data) if data else None
213273
def json(self):
        """"""

        if not self.headers and len(self.content) > 3:
            encoding = get_encoding_from_headers(self.headers)
            if encoding is not None:
                return json.loads(self.content.decode(encoding))
        return json.loads(self.content)
988600
def loadJson(self, data):
        """"""
        if not isinstance(data, dict):
            data = json.loads(data)
        self.__dict__.update(data)
        self.inflate() # restore objects from str values
        #if self.ports:  self._gotPorts = True
        return self
939194
def json(value):
    '''
    
    '''
    uncleaned = jsonlib.dumps(value)
    clean = bleach.clean(uncleaned)
    return mark_safe(clean)
1208297
function readJSON(filepath){
	var buffer = {};
	try{
		buffer = JSON.parse(fs.readFileSync(filepath, { encoding:'utf8' }));
	} catch(error){}
	return buffer;
}
77838
def json_loads(data):
    """"""
    if data is None:
        return ""

    if data == "-":
        return json.load(sys.stdin)
    elif os.path.exists(data):
        with open(data, 'r') as handle:
            return json.load(handle)
    else:
        return json.loads(data)
196983
def dump(self):
    """"""
    return json.dumps(
        self.primitive,
        sort_keys=True,
        ensure_ascii=False,
        separators=(',', ':'))
1188430
def get_content_json(request):
    """"""
    result = _get_content_json()

    resp = request.response
    resp.status = "200 OK"
    resp.content_type = 'application/json'
    resp.body = json.dumps(result)
    return result, resp
184468
function readJson(filePath) {
    var json = {};

    try {
        var content = fs.readFileSync(path.resolve(process.cwd(), filePath), {
            encoding: 'utf-8'
        });
        json = JSON.parse(stripJsonComments(content));
    } catch (error) {
        console.error(error);
    }

    return json;
}
221795
def write_json(filename, content):
    '''
    
    '''

    j = _dumps(content, indent=4, sort_keys=True)
    if j:
        return write_file(filename, j)
319449
def load_json(self, json):
        """"""
        for key in json:
            if key == "wandb_version":
                continue
            self._items[key] = json[key].get('value')
            self._descriptions[key] = json[key].get('desc')
1269727
async def json(self, *, encoding: Optional[str]=None) -> Any:
        """"""
        data = await self.read(decode=True)
        if not data:
            return None
        encoding = encoding or self.get_charset(default='utf-8')
        return json.loads(data.decode(encoding))