Function parseFromValue [src]
Alias for std.json.static.parseFromValue
Like parseFromSlice, but the input is an already-parsed std.json.Value object.
Only options.ignore_unknown_fields is used from options.
Prototype
pub fn parseFromValue( comptime T: type, allocator: Allocator, source: Value, options: ParseOptions, ) ParseFromValueError!Parsed(T)
Parameters
T: type
allocator: Allocator
source: Value
options: ParseOptions
Possible Errors
The input was empty or contained an invalid character
The result cannot fit in the type specified
Source
pub fn parseFromValue(
comptime T: type,
allocator: Allocator,
source: Value,
options: ParseOptions,
) ParseFromValueError!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 parseFromValueLeaky(T, parsed.arena.allocator(), source, options);
return parsed;
}