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)
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)