Documentation
¶
Overview ¶
Package input reads one input document, JSON or YAML, and reports every problem with it as diagnostics that say where the problem is. No diagnostic carries a value of the input: the texts of encoding/json, of the YAML library, and of the schema library quote the input, so none of them is ever passed on.
Index ¶
Constants ¶
const UnsupportedVersion = "schema.unsupported_version"
UnsupportedVersion is the code of a document whose schema_version the schema does not accept. Check reports nothing else about such a document.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Document ¶
type Document struct {
// Value is nil, bool, string, json.Number, []any or map[string]any.
Value any
// contains filtered or unexported fields
}
Document is one input after it was read: the JSON value, and where each part of it stands in the text.
func DecodeJSON ¶
DecodeJSON reads JSON text. The document is nil when nothing could be read.
func DecodeYAML ¶
DecodeYAML reads YAML text that holds one document, and gives the JSON value it stands for. The document is nil when nothing could be read.
The YAML library only parses. What a value is, is decided here by the core schema of YAML 1.2, the reading that editors apply: a scalar in quotes or in block form is a text, and a plain scalar is null, a boolean, or a number when it has that form, and a text otherwise. So a date stays the text that was written. Aliases, tags, merge keys, and directives are not read.
type Schema ¶
type Schema struct {
// contains filtered or unexported fields
}
Schema is a compiled JSON Schema that reports problems as diagnostics.
func MustCompile ¶
MustCompile compiles schema bytes, with the schemas that they refer to. It panics on a broken schema, which is a defect of the build, and never loads anything but the bytes it was given.