Skip to main content

Module meta_json

Module meta_json 

Source
Expand description

Canonical JSON wire codec for MetaValue.

Metadata values cross several wire boundaries — the CLI query --format json output and the WASI FFI JSON-RPC surface. Each used to re-implement the same MetaValue ↔ JSON match, so adding a variant meant editing every copy and the copies could silently drift (the type tag in particular). This module is the single source of that mapping.

The WASM binding deliberately keeps serde_json a host-only dev-dependency (it emits a typed enum instead), so it cannot call meta_value_to_json — but it shares meta_value_type_tag, which is serde_json-free, so the drift-prone type tag stays single-sourced across every surface.

The plugin (MetaValueData, MessagePack) and the Component-Model WIT meta-value are separate, narrower wire contracts and are intentionally not routed through this JSON codec.

Functions§

json_to_meta_value
Parse a metadata value from its canonical JSON form (the inverse of meta_value_to_json for the round-trippable cases).
meta_value_to_json
Canonical JSON form of a metadata value.
meta_value_type_tag
The wire type tag for a metadata value ("string", "int", "amount", …).