Skip to main content

Module json_view

Module json_view 

Source
Expand description

A structured view of a value a host parsed somewhere else.

§Why there is a value type here

This crate takes no serialization dependency, for the same reason SplitLayout converts to plain records instead of deriving Serialize: a product-neutral component must not decide which parsing crate an application depends on. JsonValue is the smallest shape that expresses a JSON document faithfully, and a host converts into it from whatever it already parses with.

Two choices in it are deliberate.

  • A number is carried as the text the document contained. A f64 cannot hold every integer a JSON document can write, and it cannot tell 1.10 from 1.1; this crate also formats no numbers (docs/coverage.md records that gap), so re-rendering one would be inventing digits.
  • An object is a Vec of pairs rather than a map. JSON documents have an order and may repeat a key; a map would silently reorder the first and drop the second, and a viewer that quietly edits its document is the thing this component exists not to be.

§Absent, null, and empty are three facts

A key that is not in the document produces no row at all. A key whose value is null produces a row reading null. A key holding an empty object produces a row reading {} that discloses nothing. All three are different statements about the document, and a viewer that renders them alike is lying about one of them.

§Withheld is not absent

A caller that must not show a subtree replaces it with JsonValue::Redacted, which carries a description of the shape and never the value. The secret therefore never reaches this component, so no rendering path, no snapshot, and no export can leak it — and the row still exists, marked withheld, because a secret drawn as an absence tells the reader the document does not contain it.

§Virtualization

The view lays out only the rows its viewport holds, over the same uniform_list primitive List and DataGrid use, so the same rule applies: only rendered rows publish semantic nodes, and the container carries how many rows are currently disclosed. It does not build on Tree, which draws one label per node and has no slot for a second column; a key and a typed value drawn as one string would lose the distinction between the name of a thing and what it holds.

Structs§

JsonView
A collapsible view of a structured value.

Enums§

JsonValue
A JSON value, plus the one thing JSON cannot say: that a subtree is being withheld on purpose.
ValueKind
What kind of thing a row holds, which is the one fact its node publishes.