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 intoJson

json/value::intoJson


Generics

◻ T: Serialize

Inputs

⇥ value: Stream<T>

Outputs

↦ json: Stream<Option<Json>> (json::Json)


Emit each value of the stream as JSON, or none if it cannot be written as JSON, such as secrets.

Numbers, booleans, strings, bytes and characters become JSON scalars, void and none become null, vectors become arrays, and data types are written as they define, such as StringMap as an object of strings.

graph LR
     T("intoJson<u64>()")
     A["42 … 7"] -->|value| T
     T -->|json| B["〈42〉 … 〈7〉"]

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