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. See https://docs.tigrisdata.com/overview/schema#data-types for more details about JSON types.
Mapping ¶
Composite types
*types.Document {"$k": ["<key 1>", "<key 2>", ...], "<key 1>": <value 1>, "<key 2>": <value 2>, ...}
TODO *types.Array JSON array
Scalar types
float64 JSON number (double format)
string JSON string
types.Binary {"$b": "<base 64 string>", "s": <subtype number>}
types.ObjectID JSON string (byte format, length is 12 bytes)
bool JSON true|false values
time.Time JSON string (date-time RFC3339 format)
TODO types.NullType JSON null
types.Regex {"$r": "<string without terminating 0x0>", "o": "<string without terminating 0x0>"}
int32 JSON number (int32 format)
types.Timestamp {"$t": "<number as string>"}
int64 JSON number (int64 format)
TODO Decimal128 {"$n": "<number as string>"}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Schema ¶
type Schema struct {
Title string `json:"title,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"`
// those fields are not used, but required to be there for DisallowUnknownFields
Description string `json:"description,omitempty"`
CollectionType string `json:"collection_type,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.