Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

skipValue

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

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

File

lib/std/json/Scanner.zig:252

Code

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.
    }
}