def _file_with_keys(file_obj, key_path=None, parse_decimal=False):
    """read json with keys

    Parameters
    ----------
    file_obj : object
        object with read method
    key_path : list[str]
        key to index befor parsing
    parse_decimal : bool
        whether to parse numbers as Decimal instances (retains exact precision)

    Notes
    -----
    ijson outputs decimals as Decimal class (for arbitrary precision)

    """
    key_path = [] if key_path is None else key_path

    try:
        objs = ijson.items(file_obj, '.'.join(key_path))
    except NameError:
        warnings.warn('ijson package not found in environment, \
        please install for on-disk key indexing', ImportWarning)
        data = json.load(
            file_obj, parse_float=Decimal if parse_decimal else float,
            object_hook=decode)
        return indexes(data, key_path)
    try:
        data = next(objs)  # .next()
    except StopIteration:
        raise KeyError('key path not available in json: {}'.format(key_path))

    # by default ijson parses Decimal values
    if not parse_decimal:
        convert_type(data, Decimal, float, in_place=True)

    datastr = json.dumps(data)
    data = json.loads(datastr, object_hook=decode)

    return data
read json with keys

    Parameters
    ----------
    file_obj : object
        object with read method
    key_path : list[str]
        key to index befor parsing
    parse_decimal : bool
        whether to parse numbers as Decimal instances (retains exact precision)

    Notes
    -----
    ijson outputs decimals as Decimal class (for arbitrary precision)