parseFromTokenSource
scanner_or_reader must be either a *std.json.Scanner with complete input or a *std.json.Reader.
Note that error.BufferUnderrun is not actually possible to return from this function.
Function parameters
Parameters
- T:type
- scanner_or_reader:anytype
Controls how to deal with various inconsistencies between the JSON document and the Zig struct type passed in.
Types
- ParseOptions
- Controls how to deal with various inconsistencies between the JSON document and the Zig struct type passed in.
Functions in this namespace
Functions
- parseFromSlice
- Parses the json document from `s` and returns the result packaged in a `std.json.Parsed`.
- parseFromSliceLeaky
- Parses the json document from `s` and returns the result.
- parseFromTokenSource
- `scanner_or_reader` must be either a `*std.json.Scanner` with complete input or a `*std.json.Reader`.
- parseFromTokenSourceLeaky
- `scanner_or_reader` must be either a `*std.json.Scanner` with complete input or a `*std.json.Reader`.
- parseFromValue
- Like `parseFromSlice`, but the input is an already-parsed `std.json.Value` object.
- ParseError
- The error set that will be returned when parsing from `*Source`.
- innerParse
- This is an internal function called recursively
- innerParseFromValue
- This is an internal function called recursively
Error sets in this namespace
Error Sets
Source
Implementation
pub fn parseFromTokenSource(
comptime T: type,
allocator: Allocator,
scanner_or_reader: anytype,
options: ParseOptions,
) ParseError(@TypeOf(scanner_or_reader.*))!Parsed(T) {
var parsed = Parsed(T){
.arena = try allocator.create(ArenaAllocator),
.value = undefined,
};
errdefer allocator.destroy(parsed.arena);
parsed.arena.* = ArenaAllocator.init(allocator);
errdefer parsed.arena.deinit();
parsed.value = try parseFromTokenSourceLeaky(T, parsed.arena.allocator(), scanner_or_reader, options);
return parsed;
}