json
json
JSON builtin namespace.
Runtime support: native and WebAssembly.
Import
use json;
Functions
| Function | Description |
|---|---|
encode | Encodes the value as a JSON string through the schema inferred from the checked argument, or through the named schema T when written as encode::<T>. A value with no concrete encodable schema, such as a dynamic map, is rejected at compile time. |
decode | Decodes a JSON document and projects the decoded tree onto the named schema T. Duplicate object keys are rejected. A malformed document is a fatal host error rather than a Result, so callers cannot branch on decode failure; the ::<T> type argument is required at the RSS boundary. |
Function details
encode
fn encode::<T>(value: T) -> string
Encodes the value as a JSON string through the schema inferred from the checked argument, or through the named schema T when written as encode::<T>. A value with no concrete encodable schema, such as a dynamic map, is rejected at compile time.
decode
fn decode::<T>(text: string) -> T
Decodes a JSON document and projects the decoded tree onto the named schema T. Duplicate object keys are rejected. A malformed document is a fatal host error rather than a Result, so callers cannot branch on decode failure; the ::<T> type argument is required at the RSS boundary.