Пример #1
0
def _to_json(data):
    try:
        return Box.from_json(data)
    except JSONDecodeError:
        raise BoxError('File is not JSON as expected')
    except BoxError:
        return BoxList.from_json(data)
Пример #2
0
def _to_json(file, encoding, errors, **kwargs):
    try:
        return Box.from_json(filename=file,
                             encoding=encoding,
                             errors=errors,
                             **kwargs)
    except JSONDecodeError:
        raise BoxError("File is not JSON as expected")
    except BoxError:
        return BoxList.from_json(filename=file,
                                 encoding=encoding,
                                 errors=errors,
                                 **kwargs)