silk.json.schema_value.
Convert TOML documents to the existing JSON value tree without rounding numbers.
When to use#
Use SchemaValue.parseToml to feed TOML instances or schemas to JSON Schema validation.
Use silk.json.value.Json.parseExact for JSON source. Both return silk.json.value.Value.
Details#
Tables become objects, arrays retain order, and dates and times become source strings.
Numbers use JsonNumber.Decimal: underscores and leading pluses are removed, and base-prefixed
integers become exact decimal. Infinity and NaN are rejected because JSON has no such numbers.
Import as SchemaValue with import silk.json.schema_value { SchemaValue }.
Public declarations: 2.
ValueError#
pub enum ValueErrorA TOML tree cannot be represented as a JSON data-model tree.
NonFiniteNumber#
NonFiniteNumberA source number is NaN or positive or negative infinity.
InvalidTomlValue#
InvalidTomlValueA manually constructed TOML scalar or child has an invalid shape or spelling.
SchemaValue#
pub struct SchemaValueConvert TOML into the shared JSON value tree for instance and schema processing.
Implementation SchemaValue#
impl SchemaValueAssociated function parseToml#
pub effect fn parseToml(bytes: &[u8]) -> Value
! TomlError | ValueError | OutOfMemoryError ? &mut AllocatorParses TOML as a JSON object tree, resolving dotted keys, tables, and arrays of tables.
Dates and times become source strings. Numbers use exact JsonNumber.Decimal spellings,
including base-prefixed integers and numbers containing underscores.
Errors#
TomlErrorfor invalid TOML, duplicate definitions, or excessive nesting.ValueError.NonFiniteNumberfor any infinity or NaN in the document.OutOfMemoryErrorif the allocator cannot supply either tree.
Associated function fromToml#
pub effect fn fromToml(value: &TomlValue) -> Value
! ValueError | OutOfMemoryError ? &mut AllocatorCopies a TOML tree into an independently owned JSON tree without rounding its numbers. Tables become objects, arrays retain order, and dates and times become their source strings. Base-prefixed integers become decimal; numeric underscores and leading pluses are removed.
Errors#
ValueError.NonFiniteNumberfor infinity or NaN.ValueError.InvalidTomlValuefor malformed numeric values, children, or duplicate keys.OutOfMemoryErrorif the allocator cannot supply the copy.
Category: Data formats.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.