Documentation
¶
Overview ¶
Package tjson provides converters from/to JSON with JSON Schema for built-in and `types` types.
See contributing guidelines and documentation for package `types` for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Schema ¶
type Schema struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Type SchemaType `json:"type,omitempty"`
Format SchemaFormat `json:"format,omitempty"`
Properties map[string]*Schema `json:"properties,omitempty"`
Items *Schema `json:"items,omitempty"`
PrimaryKey []string `json:"primary_key,omitempty"`
}
Schema represents a supported subset of JSON Schema.
func DocumentSchema ¶
DocumentSchema returns a JSON Schema for the given top-level document. Top-level documents are documents that must have _id which will be used as primary key.
func (*Schema) Equal ¶
Equal returns true if the schemas are equal. For composite types schemas are equal if their types and subschemas are equal. For scalar types schemas are equal if their types and formats are equal.
type SchemaFormat ¶
type SchemaFormat string
SchemaFormat represents additional information about JSON value type in JSON Schema.
const ( EmptyFormat SchemaFormat = "" // For Number. Double SchemaFormat = "double" Float SchemaFormat = "float" // For Integer. Int64 SchemaFormat = "int64" Int32 SchemaFormat = "int32" // For String. Byte SchemaFormat = "byte" UUID SchemaFormat = "uuid" DateTime SchemaFormat = "date-time" )
JSON value formats.
type SchemaType ¶
type SchemaType string
SchemaType represents JSON value type in JSON Schema.
const ( Integer SchemaType = "integer" Number SchemaType = "number" String SchemaType = "string" Boolean SchemaType = "boolean" Array SchemaType = "array" Object SchemaType = "object" )
JSON value types defined by the JSON Schema.