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#

silk
pub enum ValueError

A TOML tree cannot be represented as a JSON data-model tree.

NonFiniteNumber#

silk
NonFiniteNumber

A source number is NaN or positive or negative infinity.

InvalidTomlValue#

silk
InvalidTomlValue

A manually constructed TOML scalar or child has an invalid shape or spelling.

SchemaValue#

silk
pub struct SchemaValue

Convert TOML into the shared JSON value tree for instance and schema processing.

Implementation SchemaValue#

silk
impl SchemaValue

Associated function parseToml#

silk
pub effect fn parseToml(bytes: &[u8]) -> Value
    ! TomlError | ValueError | OutOfMemoryError ? &mut Allocator

Parses 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#

  • TomlError for invalid TOML, duplicate definitions, or excessive nesting.

  • ValueError.NonFiniteNumber for any infinity or NaN in the document.

  • OutOfMemoryError if the allocator cannot supply either tree.

Associated function fromToml#

silk
pub effect fn fromToml(value: &TomlValue) -> Value
    ! ValueError | OutOfMemoryError ? &mut Allocator

Copies 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.NonFiniteNumber for infinity or NaN.

  • ValueError.InvalidTomlValue for malformed numeric values, children, or duplicate keys.

  • OutOfMemoryError if 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.

View the source of this page