Helper function to read JSON file as OrderedDict
773879
def _read_json_file(self, json_file):
        

        self.log.debug("Reading '%s' JSON file..." % json_file)

        with open(json_file, 'r') as f:
            return json.load(f, object_pairs_hook=OrderedDict)
1240912
def sort_dict(self, data, key):
    ''''''
    return sorted(data, key=itemgetter(key)) if data else []
804623
def todict(self):
        """"""
        return OrderedDict((name, self[i]) for i, name in enumerate(self._fields))
302040
def _read_json(fn_json):
    """"""
    is_json = set()
    is_db = {}
    with open(fn_json) as handle:
        data = json.load(handle)
        # original Py 2.y core
        #for item in data[0].values():
        #    seqs_name = map(lambda (x): x.keys(), item['seqs'])
        # rewrite by 2to3
        for item in list(data[0].values()):
            seqs_name = [list(x.keys()) for x in item['seqs']]
            db_name = item['valid'] if "valid" in item else None
            [is_json.add(name[0]) for name in seqs_name]
            if db_name:
                [is_db.update({name[0]: ",".join(db_name)}) for name in seqs_name]
    return is_json, is_db
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
772049
def _ordered(self, odict):
        """"""
        ndict = OrderedDict()

        if isinstance(odict, CatDict) or isinstance(odict, Entry):
            key = odict.sort_func
        else:
            key = None

        nkeys = list(sorted(odict.keys(), key=key))
        for key in nkeys:
            if isinstance(odict[key], OrderedDict):
                odict[key] = self._ordered(odict[key])
            if isinstance(odict[key], list):
                if (not (odict[key] and
                         not isinstance(odict[key][0], OrderedDict))):
                    nlist = []
                    for item in odict[key]:
                        if isinstance(item, OrderedDict):
                            nlist.append(self._ordered(item))
                        else:
                            nlist.append(item)
                    odict[key] = nlist
            ndict[key] = odict[key]

        return ndict
314104
def from_file(cls, f):
        

        with open_file_like(f, 'r') as fp:
            return cls(json.load(fp))
918641
def _read_jsonl(filepath, kwargs):
    """"""
    with open(filepath) as data_file:
        data = [json.loads(line, **kwargs)
                for line in data_file
                if len(line) > 0]
    return data
14555
def as_ordereddict(self):
        """"""
        if six.PY2:
            d = OrderedDict()
            copied = dict(self)
            for key in self:
                d[key] = copied[key]
        else:
            d = OrderedDict(self)
        return d
543876
def read_json(fh, byteorder, dtype, count, offsetsize):
    """"""
    data = fh.read(count)
    try:
        return json.loads(unicode(stripnull(data), 'utf-8'))
    except ValueError:
        log.warning('read_json: invalid JSON')
1208297
function readJSON(filepath){
	var buffer = {};
	try{
		buffer = JSON.parse(fs.readFileSync(filepath, { encoding:'utf8' }));
	} catch(error){}
	return buffer;
}
113230
def jsonify(data, pretty=False, **kwargs):
    
    isod = isinstance(data, OrderedDict)
    params = {
        'for_json': True,
        'default': _complex_encode,
    }
    if pretty:
        params['indent'] = 2
        params['sort_keys'] = False if isod else True
    params.update(kwargs)
    try:
        return json.dumps(data, ensure_ascii=False, **params)
    except UnicodeDecodeError:
        return json.dumps(data, **params)
289925
def iterdict(self):
        """"""
        from collections import OrderedDict

        headers = None

        for row in self:

            if headers is None:
                headers = row
                continue

            yield OrderedDict(zip(headers, row))
321325
def ordered_dict_to_dict(d):
    
    ret = {}
    new_d = deepcopy(d)
    for k, v in new_d.items():
        if isinstance(v, OrderedDict):
            v = dict(v)
        if isinstance(v, dict):
            v = ordered_dict_to_dict(v)
        ret[k] = v
    return ret
897512
def read_moc_json(moc, filename=None, file=None):
    

    if file is not None:
        obj = _read_json(file)
    else:
        with open(filename, 'rb') as f:
            obj = _read_json(f)

    for (order, cells) in obj.items():
        moc.add(order, cells)
296852
def get_csv_from_json(d):
    
    logger_jsons.info("enter get_csv_from_json")
    csv_data = OrderedDict()

    if "paleoData" in d:
        csv_data = _get_csv_from_section(d, "paleoData", csv_data)

    if "chronData" in d:
        csv_data = _get_csv_from_section(d, "chronData", csv_data)

    logger_jsons.info("exit get_csv_from_json")
    return csv_data
38992
def load_json(file):
    """"""
    here = os.path.dirname(os.path.abspath(__file__))
    with open(os.path.join(here, file)) as jfile:
        data = json.load(jfile)
    return data