tiny.preserves.fromJsonValue
Defined in json.
Returns the Preserves value that json_value describes, allocated with alloc, for code that already holds a parsed std.json.Value, so the JSON is parsed once.
Source
Source: lib/preserves/src/json.zig:313
zig
/// Returns the Preserves value that `json_value` describes, allocated with `alloc`, for code that/// already holds a parsed `std.json.Value`, so the JSON is parsed once. The result copies every/// string it keeps, so it owns all its memory and borrows nothing from `json_value`. JSON null/// becomes the symbol `null`, an integer that fits 64 bits becomes an integer, any other finite/// number becomes a double, and a number outside those ranges becomes the symbol `NaN`. Strings/// stay strings, and arrays become sequences. The reserved member names are tried in order:/// `__discard__`, `__record__`, `__embedded__`, `$rest`, `$capture`, `$bind`, then `"type"`. Any/// other object becomes a dictionary with string keys. A `"type"` naming a protocol record becomes/// that record, and each missing field becomes the discard pattern. Any other `"type"` becomes a/// record labeled with that name and one dictionary field holding the other members. A `__record__`/// string label becomes a symbol label. An `__embedded__` member becomes an embedded value that/// owns the decoded member, and copying or freeing the outer value copies or frees it. Decoding the/// output of `toJsonString` for an embedded value yields an embedded value that holds the pointer's/// decimal string.pub fn fromJsonValue(alloc: Allocator, json_value: std.json.Value) !Value { return jsonToValue(alloc, json_value);}Source: lib/preserves/src/root.zig:306
zig
pub const fromJsonValue = json.fromJsonValue;Audit
| Definitions | 1 |
|---|---|
| Public names | 2 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |