Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Treatment fromJson

json/value::fromJson


Generics

◻ T: Deserialize

Inputs

⇥ json: Stream<Json> (json::Json)

Outputs

↦ value: Stream<Option<T>>


Emit each JSON value of the stream as a value of type T, or none if it cannot be one.

Numbers, booleans, strings and null (for void) become the core types they fit in, arrays become vectors, null becomes none for options, and data types are read as they define, such as StringMap from an object of strings. Secrets are never read from JSON.

graph LR
     T("fromJson<u64>()")
     A["42 … \"text\""] -->|json| T
     T -->|value| B["〈42〉 … 〈none〉"]

     style A fill:#ffffff,stroke:#ffffff
     style B fill:#ffffff,stroke:#ffffff