Function skipValue [src]

This function is only available after endInput() (or initCompleteInput()) has been called. If the next token type is .object_begin or .array_begin, this function calls next() repeatedly until the corresponding .object_end or .array_end is found. If the next token type is .number or .string, this function calls next() repeatedly until the (non .partial_*) .number or .string token is found. If the next token type is .true, .false, or .null, this function calls next() once. The next token type must not be .object_end, .array_end, or .end_of_document; see peekNextTokenType().

Prototype

pub fn skipValue(self: *@This()) SkipError!void

Parameters

self: *@This()

Possible Errors

OutOfMemory Error
SyntaxError Error
UnexpectedEndOfInput Error

Source

pub fn skipValue(self: *@This()) SkipError!void { assert(self.is_end_of_input); // This function is not available in streaming mode. switch (self.peekNextTokenType() catch |e| switch (e) { error.BufferUnderrun => unreachable, else => |err| return err, }) { .object_begin, .array_begin => { self.skipUntilStackHeight(self.stackHeight()) catch |e| switch (e) { error.BufferUnderrun => unreachable, else => |err| return err, }; }, .number, .string => { while (true) { switch (self.next() catch |e| switch (e) { error.BufferUnderrun => unreachable, else => |err| return err, }) { .partial_number, .partial_string, .partial_string_escaped_1, .partial_string_escaped_2, .partial_string_escaped_3, .partial_string_escaped_4, => continue, .number, .string => break, else => unreachable, } } }, .true, .false, .null => { _ = self.next() catch |e| switch (e) { error.BufferUnderrun => unreachable, else => |err| return err, }; }, .object_end, .array_end, .end_of_document => unreachable, // Attempt to skip a non-value token. } }