Skip to main content

Module json

Module json 

Source
Expand description

Conversion between JSON text and techy’s serialized values and wire segments.

A techy serialized value (SerialValue) has at most one JSON form (a value holding a map key that begins with $ has none), and two values have the same JSON text exactly when they are equal. Comparing two projections as values and comparing their JSON text therefore always agree, so a golden file can hold a projection as readable JSON that a person may edit, without weakening the comparison.

A wire segment (Segment) is one unit of techy’s serialized stream, as a serialization session emits it. Its JSON form is written on one line, so that a stream is one segment per line; flm dump --view wire prints it that way.

from_serde converts any value serde can serialize, such as a serde_json::json! literal, into a serialized value, which is how a test writes an expected value.

Functions§

from_json
Reads a serialized value from JSON text.
from_serde
Converts any value that serde can serialize into a techy serialized value.
segment_from_line
Reads a wire segment from one line of JSON written by segment_line.
segment_line
Writes a wire segment as one line of JSON, with no line break inside it.
to_json
Writes a serialized value as JSON on one line, with no space between the tokens.
to_json_pretty
Writes a serialized value as indented JSON: two spaces per level, no trailing newline.

Type Aliases§

JsonError
The error type of the JSON functions of this module: serde_json’s error.