std.json.Scanner.AllocError
- Kind
- type
- Module
std.json.Scanner
Source: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
The entries of std.json.Scanner in the Zig reference. This page has 51 cards.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn allocNextIntoArrayList(self: *@This(), value_list: *std.array_list.Managed(u8), when: AllocWhen) AllocIntoArrayListError!?[]const u8
Equivalent to `allocNextIntoArrayListMax(value_list, when, default_max_value_len);`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn allocNextIntoArrayListMax(self: *@This(), value_list: *std.array_list.Managed(u8), when: AllocWhen, max_value_len: usize) AllocIntoArrayListError!?[]const u8
The next token type must be either `.number` or `.string`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
Used by `json.reader`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
For security, the maximum size allocated to store a single string or number value is limited to 4MiB by default.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn deinit(self: *@This()) void
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
To enable diagnostics, declare `var diagnostics = Diagnostics{};` then call `source.enableDiagnostics(&diagnostics);` where `source` is either a `std.json.Reader` or a `std.json.Scanner` that has just been initialized.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn getByteOffset(self: *const @This()) u64
Starts at 0.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn getColumn(self: *const @This()) u64
Starts at 1.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn getLine(self: *const @This()) u64
Starts at 1.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn enableDiagnostics(self: *@This(), diagnostics: *Diagnostics) void
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn endInput(self: *@This()) void
Call this when you will no longer call `feedInput()` anymore.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn ensureTotalStackCapacity(self: *@This(), height: usize) Allocator.Error!void
Pre allocate memory to hold the given number of nesting levels. `stackHeight()` up to the given number will not cause allocations.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn feedInput(self: *@This(), input: []const u8) void
Call this whenever you get `error.BufferUnderrun` from `next()`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn initCompleteInput(allocator: Allocator, complete_input: []const u8) @This()
Use this if your input is a single slice.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn initStreaming(allocator: Allocator) @This()
The allocator is only used to track `[]` and `{}` nesting levels.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn isNumberFormattedLikeAnInteger(value: []const u8) bool
For the slice you get from a `Token.number` or `Token.allocated_number`, this function returns true if the number doesn't contain any fraction or exponent components, and is not `-0`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn next(self: *@This()) NextError!Token
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn nextAlloc(self: *@This(), allocator: Allocator, when: AllocWhen) AllocError!Token
Equivalent to `nextAllocMax(allocator, when, default_max_value_len);` This function is only available after `endInput()` (or `initCompleteInput()`) has been called.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn nextAllocMax(self: *@This(), allocator: Allocator, when: AllocWhen, max_value_len: usize) AllocError!Token
This function is only available after `endInput()` (or `initCompleteInput()`) has been called.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn peekNextTokenType(self: *@This()) PeekError!TokenType
Seeks ahead in the input until the first byte of the next token (or the end of the input) determines which type of token will be returned from the next `next*()` call.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
All `next*()` methods here handle `error.BufferUnderrun` from `std.json.Scanner`, and then read from the reader.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn allocNextIntoArrayList(self: *@This(), value_list: *std.array_list.Managed(u8), when: AllocWhen) Reader.AllocError!?[]const u8
Equivalent to `allocNextIntoArrayListMax(value_list, when, default_max_value_len);`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn allocNextIntoArrayListMax(self: *@This(), value_list: *std.array_list.Managed(u8), when: AllocWhen, max_value_len: usize) Reader.AllocError!?[]const u8
Calls `std.json.Scanner.allocNextIntoArrayListMax` and handles `error.BufferUnderrun`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn deinit(self: *@This()) void
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn enableDiagnostics(self: *@This(), diagnostics: *Diagnostics) void
Calls `std.json.Scanner.enableDiagnostics`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn ensureTotalStackCapacity(self: *@This(), height: usize) Allocator.Error!void
Calls `std.json.Scanner.ensureTotalStackCapacity`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn init(allocator: Allocator, io_reader: *std.Io.Reader) @This()
The allocator is only used to track `[]` and `{}` nesting levels.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn next(self: *@This()) Reader.NextError!Token
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn nextAlloc(self: *@This(), allocator: Allocator, when: AllocWhen) Reader.AllocError!Token
Equivalent to `nextAllocMax(allocator, when, default_max_value_len);` See also `std.json.Token` for documentation of `nextAlloc*()` function behavior.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn nextAllocMax(self: *@This(), allocator: Allocator, when: AllocWhen, max_value_len: usize) Reader.AllocError!Token
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn peekNextTokenType(self: *@This()) Reader.PeekError!TokenType
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn skipUntilStackHeight(self: *@This(), terminal_stack_height: usize) Reader.NextError!void
Like `std.json.Scanner.skipUntilStackHeight()` but handles `error.BufferUnderrun`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn skipValue(self: *@This()) Reader.SkipError!void
Like `std.json.Scanner.skipValue`, but handles `error.BufferUnderrun`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn stackHeight(self: *const @This()) usize
Calls `std.json.Scanner.stackHeight`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn skipUntilStackHeight(self: *@This(), terminal_stack_height: usize) NextError!void
Skip tokens until an `.object_end` or `.array_end` token results in a `stackHeight()` equal the given stack height.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn skipValue(self: *@This()) SkipError!void
This function is only available after `endInput()` (or `initCompleteInput()`) has been called.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn stackHeight(self: *const @This()) usize
The depth of `{}` or `[]` nesting levels at the current position.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
This is only used in `peekNextTokenType()` and gives a categorization based on the first byte of the next token that will be emitted from a `next*()` call.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.
pub fn validate(allocator: Allocator, s: []const u8) Allocator.Error!bool
Scan the input and check for malformed JSON. On `SyntaxError` or `UnexpectedEndOfInput`, returns `false`.
std.json.ScannerSource: codeberg.org, ziglang.org. JSON record. This entry is a card. Help write this page.