How to use the ijson.backend.UnexpectedSymbol function in ijson

To help you get started, we’ve selected a few ijson examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ravendb / ravendb-python-client / pyravendb / subscriptions / data.py View on Github external
def parse_array(lexer):
        yield ('start_array', None)
        try:
            pos, symbol = next(lexer)
            if symbol != ']':
                while True:
                    for event in IncrementalJsonParser.parse_value(lexer, symbol, pos):
                        yield event
                    pos, symbol = next(lexer)
                    if symbol == ']':
                        break
                    if symbol != ',':
                        raise ijson.backend.UnexpectedSymbol(symbol, pos)
                    pos, symbol = next(lexer)
            yield ('end_array', None)
        except StopIteration:
            raise ijson.backend.common.IncompleteJSONError('Incomplete JSON data')
github ravendb / ravendb-python-client / pyravendb / subscriptions / subscription.py View on Github external
if not node_to_redirect_to:
                raise AggregateException(exception, InvalidOperationException(
                    "Could not redirect to {0}, "
                    "because it was not found in local topology, even after retrying".format(
                        exception.appropriate_node)))

            self._redirect_node = node_to_redirect_to
            return True
        if isinstance(exception, SubscriptionChangeVectorUpdateConcurrencyException):
            return True
        if isinstance(exception, (
                SubscriptionInUseException, SubscriptionDoesNotExistException, SubscriptionClosedException,
                SubscriptionInvalidStateException, DatabaseDoesNotExistException, AuthorizationException,
                AllTopologyNodesDownException, SubscriberErrorException, ValueError, NotImplementedError,
                AttributeError, ijson.backend.UnexpectedSymbol)):
            self.close()
            return False
        self.assert_last_connection_failure()
        return True
github ravendb / ravendb-python-client / pyravendb / subscriptions / data.py View on Github external
def parse_object(lexer):
        yield ('start_map', None)
        try:
            pos, symbol = next(lexer)
            if symbol != '}':
                while True:
                    if symbol[0] != '"':
                        raise ijson.backend.UnexpectedSymbol(symbol, pos)
                    yield ('map_key', IncrementalJsonParser.unescape(symbol[1:-1]))
                    pos, symbol = next(lexer)
                    if symbol != ':':
                        raise ijson.backend.UnexpectedSymbol(symbol, pos)
                    for event in IncrementalJsonParser.parse_value(lexer, None, pos):
                        yield event
                    pos, symbol = next(lexer)
                    if symbol == '}':
                        break
                    if symbol != ',':
                        raise ijson.backend.UnexpectedSymbol(symbol, pos)
                    pos, symbol = next(lexer)
            yield ('end_map', None)
        except StopIteration:
            raise ijson.backend.common.IncompleteJSONError('Incomplete JSON data')
github ravendb / ravendb-python-client / pyravendb / subscriptions / data.py View on Github external
else:
                # if we got a partial token for false / null / true we need to read from the network again
                while symbol[0] in ('t', 'n') and len(symbol) < 4 or symbol[0] == 'f' and len(symbol) < 5:
                    _, nextpart = next(lexer)
                    if symbol == 'null':
                        yield ('null', None)
                    elif symbol == 'true':
                        yield ('boolean', True)
                    elif symbol == 'false':
                        yield ('boolean', False)
                    return

                try:
                    yield ('number', ijson.backend.common.number(symbol))
                except ijson.backend.decimal.InvalidOperation:
                    raise ijson.backend.UnexpectedSymbol(symbol, pos)
        except StopIteration:
            raise ijson.backend.common.IncompleteJSONError('Incomplete JSON data')
github ravendb / ravendb-python-client / pyravendb / subscriptions / data.py View on Github external
pos, symbol = next(lexer)
            if symbol != '}':
                while True:
                    if symbol[0] != '"':
                        raise ijson.backend.UnexpectedSymbol(symbol, pos)
                    yield ('map_key', IncrementalJsonParser.unescape(symbol[1:-1]))
                    pos, symbol = next(lexer)
                    if symbol != ':':
                        raise ijson.backend.UnexpectedSymbol(symbol, pos)
                    for event in IncrementalJsonParser.parse_value(lexer, None, pos):
                        yield event
                    pos, symbol = next(lexer)
                    if symbol == '}':
                        break
                    if symbol != ',':
                        raise ijson.backend.UnexpectedSymbol(symbol, pos)
                    pos, symbol = next(lexer)
            yield ('end_map', None)
        except StopIteration:
            raise ijson.backend.common.IncompleteJSONError('Incomplete JSON data')