Skip to main content

Module json

Module json 

Source
Expand description

Reading and writing the generated vocabulary types.

The types in crate::generated are read from a normalised document, the form crate::read produces, and written in the same spelling. Their field-by-field code is generated; what it calls is here, written by hand.

Reading is tolerant of values and strict about types. A property whose value is not the shape its range allows is read as absent, because peers send values nobody specified and one odd property should not cost the whole object. An object whose type is not the one asked for is an error, because reading a Like as a Follow is not tolerance.

Structs§

JsonError
Why a value could not be read.
Text
Natural-language text: a value in no particular language, and values per language.

Enums§

ProofPurpose
A Data Integrity proof’s purpose.
Units
A unit of length, as Place.units gives one.

Traits§

FromJson
A value that can be read from a normalised document.
ToJson
A value that can be written into a document in Ojak’s spelling.
Typed
A type documents name in their type: what an inbox listener is registered for.

Functions§

expect_type
Check that object’s type is expected.
has_type
Whether object’s type is expected, alone or among several.
id
object’s id.
link_to_image
A Link where an Image is expected, read as an Image of its href.
many
A property that may hold several values: the first of keys present, and every one of its values that reads.
many_mapped
many, with each value adjusted by map before it is read.
many_with
many, reading each value with read.
new_object
Start writing an object.
object
value as an object.
one
A property holding at most one value: the first of keys present, and the first of its values that reads.
one_mapped
one, with each value adjusted by map before it is read.
one_with
one, reading each value with read.
put_many
Write a property that may hold several values under each of keys: one value without an array, several with one, none not at all.
put_many_with
put_many, writing each value with write.
put_one
Write a property holding at most one value under each of keys.
put_one_with
put_one, writing the value with write.
put_text
Write a text property as key and {key}Map, which is how peers that do not process JSON-LD expect to find it.
reference_with
A reference, or an object read with read: how a property whose values are sent without a type reads them.
text
A text property, under key in either of its spellings: merged, as a normalised document has it, or split into key and {key}Map.
without_type
value without its type, for a property whose values are sent without one.
write_reference
Write a reference, or an object with write.