Skip to main content

read_json

Function read_json 

Source
pub fn read_json(text: &str) -> Result<Opened<DesignFile>, FormatError>
Expand description

Reads a document from its JSON text, and says which version it was written in.

The format and version are checked first, so a file of another kind or version is refused with that reason rather than with the first field the reader does not know. A document of an older version this reader migrates from (migrate) is rewritten into the current version’s shape and then read as one, so it is held to every rule a current document is.

A document this reader takes passes the schema: beyond the types, it refuses a source’s SHA-256 that isn’t 64 lowercase hexadecimal digits, and an array where the schema has an object (which serde alone reads as a struct’s fields in order). It also refuses a few documents the schema takes, by the rules of SourceFile.

§Errors

FormatError: not JSON, not an hpr design, a version this reader doesn’t take, or not valid.