jsonschema

package module
v0.0.0-...-8f50c94 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 28, 2019 License: BSD-3-Clause Imports: 5 Imported by: 0

README

go-jsonschema

JSON Schema implementation for Go.

Documentation

Overview

Package jsonschema an implementation of JSON Schema for Go.

Index

Constants

View Source
const (
	// Draft07SchemaURL contains the JSON Schema draft-07 URL.
	Draft7SchemaURL = "http://json-schema.org/draft-07/schema#"
)
View Source
const MediaType = "application/schema+json"

MediaType represents a media type used for a JSON Schema.

4.3. JSON Schema Documents

https://tools.ietf.org/html/draft-handrews-json-schema-01#section-4.3

Variables

View Source
var (
	ArrayPool   *sync.Pool
	BooleanPool *sync.Pool
	IntegerPool *sync.Pool
	NullPool    *sync.Pool
	NumberPool  *sync.Pool
	ObjectPool  *sync.Pool
	StringPool  *sync.Pool
)

models

View Source
var (
	TypesPool       *sync.Pool
	StringArrayPool *sync.Pool
	ItemsPool       *sync.Pool
	ConstPool       *sync.Pool
	EnumPool        *sync.Pool
)

types

View Source
var (
	SchemaPool *sync.Pool
)

schema

Functions

This section is empty.

Types

type AdditionalItems

type AdditionalItems struct {
	*Schema
}

AdditionalItems represents a JSON Schema AdditionalItems type.

The elements of the array may be anything at all.

func (*AdditionalItems) IsNil

func (ai *AdditionalItems) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*AdditionalItems) MarshalJSONObject

func (ai *AdditionalItems) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*AdditionalItems) NKeys

func (*AdditionalItems) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*AdditionalItems) Reset

func (ai *AdditionalItems) Reset()

Reset implements Pooler.

Reset reset fields.

func (*AdditionalItems) UnmarshalJSONObject

func (ai *AdditionalItems) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type AdditionalItemsStream

type AdditionalItemsStream chan *AdditionalItems

AdditionalItemsStream represents a stream encoding and decoding to AdditionalItems.

func (AdditionalItemsStream) MarshalStream

func (s AdditionalItemsStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (AdditionalItemsStream) UnmarshalStream

func (s AdditionalItemsStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type AdditionalProperties

type AdditionalProperties struct {
	*Schema
}

AdditionalPropertieies is used to control the handling of extra stuff, that is, properties whose names are not listed in the properties keyword. By default any additional properties are allowed.

The additionalProperties keyword may be either a boolean or an object. If additionalProperties is a boolean and set to false, no additional properties will be allowed.

func (*AdditionalProperties) IsNil

func (ap *AdditionalProperties) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*AdditionalProperties) MarshalJSONObject

func (ap *AdditionalProperties) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*AdditionalProperties) NKeys

func (*AdditionalProperties) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*AdditionalProperties) Reset

func (ap *AdditionalProperties) Reset()

Reset implements Pooler.

Reset reset fields.

func (*AdditionalProperties) UnmarshalJSONObject

func (ap *AdditionalProperties) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type AdditionalPropertiesStream

type AdditionalPropertiesStream chan *AdditionalProperties

AdditionalPropertiesStream represents a stream encoding and decoding to AdditionalProperties.

func (AdditionalPropertiesStream) MarshalStream

func (s AdditionalPropertiesStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (AdditionalPropertiesStream) UnmarshalStream

func (s AdditionalPropertiesStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Array

type Array struct {
	Value       []interface{}
	Initialized bool
}

Array is used for ordered elements. In JSON, each element in an array may be of a different type.

func (*Array) IsNil

func (a *Array) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*Array) MarshalJSONObject

func (a *Array) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Array) NKeys

func (*Array) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*Array) Reset

func (a *Array) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Array) UnmarshalJSONObject

func (a *Array) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type ArrayStream

type ArrayStream chan *Array

ArrayStream represents a stream encoding and decoding to Array.

func (ArrayStream) MarshalStream

func (s ArrayStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (ArrayStream) UnmarshalStream

func (s ArrayStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Boolean

type Boolean struct {
	Value       bool
	Default     bool
	Initialized bool
}

Boolean matches only two special values: true and false.

Note that values that evaluate to true or false, such as 1 and 0, are not accepted by the schema.

func (*Boolean) IsNil

func (b *Boolean) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*Boolean) MarshalJSONObject

func (b *Boolean) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Boolean) NKeys

func (*Boolean) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*Boolean) Reset

func (b *Boolean) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Boolean) UnmarshalJSONObject

func (b *Boolean) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type BooleanStream

type BooleanStream chan *Boolean

BooleanStream represents a stream encoding and decoding to Boolean.

func (BooleanStream) MarshalStream

func (s BooleanStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (BooleanStream) UnmarshalStream

func (s BooleanStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Const

type Const struct {
	Type  Type
	Value []interface{}
}

Const is used to restrict a value to a single value.

func (*Const) IsNil

func (c *Const) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*Const) MarshalJSONObject

func (c *Const) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Const) NKeys

func (*Const) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal

func (*Const) Reset

func (c *Const) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Const) UnmarshalJSONObject

func (c *Const) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type ConstStream

type ConstStream chan *Const

ConstStream represents a stream encoding and decoding to Const.

func (ConstStream) MarshalStream

func (s ConstStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (ConstStream) UnmarshalStream

func (s ConstStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Default

type Default interface{}

Default specifies a default value for an item.

type Definitions

type Definitions map[string]Schema

Definitions provides a standardized location for schema authors to inline re-usable JSON Schemas into a more general schema. The keyword does not directly affect the validation result.

func (Definitions) IsNil

func (d Definitions) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (Definitions) MarshalJSONObject

func (d Definitions) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (Definitions) NKeys

func (Definitions) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (Definitions) Reset

func (d Definitions) Reset()

Reset implements Pooler.

Reset reset fields.

func (Definitions) UnmarshalJSONObject

func (d Definitions) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type DefinitionsStream

type DefinitionsStream chan *Definitions

DefinitionsStream represents a stream encoding and decoding to Definitions.

func (DefinitionsStream) MarshalStream

func (s DefinitionsStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (DefinitionsStream) UnmarshalStream

func (s DefinitionsStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type DependencyMap

type DependencyMap struct {
	Names   map[string][]string
	Schemas map[string]*Schema
}

DependencyMap represents a Dependencies map.

func (*DependencyMap) IsNil

func (dm *DependencyMap) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*DependencyMap) MarshalJSONObject

func (dm *DependencyMap) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (DependencyMap) NKeys

func (DependencyMap) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*DependencyMap) Reset

func (dm *DependencyMap) Reset()

Reset implements Pooler.

Reset reset fields.

func (*DependencyMap) UnmarshalJSONObject

func (dm *DependencyMap) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type DependencyMapStream

type DependencyMapStream chan *DependencyMap

DependencyMapStream represents a stream encoding and decoding to DependencyMap.

func (DependencyMapStream) MarshalStream

func (s DependencyMapStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (DependencyMapStream) UnmarshalStream

func (s DependencyMapStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type DraftVersion

type DraftVersion string

DraftVersion represents a Draft version.

const (
	DraftVersion4      DraftVersion = "draft04"
	DraftVersion6      DraftVersion = "draft06"
	DraftVersion7      DraftVersion = "draft07"
	DraftVersion201909 DraftVersion = "2019-09"
)

The list of Draft version.

type Enum

type Enum []*Const

Enum is used to restrict a value to a fixed set of values. It must be an array with at least one element, where each element is unique.

func (*Enum) IsNil

func (e *Enum) IsNil() bool

IsNil implements gojay.MarshalerJSONArray.

IsNil checks if instance is nil.

func (*Enum) MarshalJSONArray

func (e *Enum) MarshalJSONArray(enc *gojay.Encoder)

MarshalJSONArray implements gojay.MarshalerJSONArray.

func (*Enum) Reset

func (e *Enum) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Enum) UnmarshalJSONArray

func (e *Enum) UnmarshalJSONArray(dec *gojay.Decoder) error

UnmarshalJSONArray implements gojay.UnmarshalerJSONArray.

type EnumStream

type EnumStream chan *Enum

EnumStream represents a stream encoding and decoding to Enum.

func (EnumStream) MarshalStream

func (s EnumStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (EnumStream) UnmarshalStream

func (s EnumStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Format

type Format string

Format allows for basic semantic validation on certain kinds of string values that are commonly used. This allows values to be constrained beyond what the other tools in JSON Schema, including Regular Expressions can do.

const (
	// FormatDateTime is the Date and time together. for example, 2018-11-13T20:20:39+00:00.
	FormatDateTime Format = "date-time"

	// FormatTime is the Time. for example, 20:20:39+00:00.
	//
	// New in draft 7.
	FormatTime Format = "time"

	// FormatDate is the Date. for example, 2018-11-13.
	//
	// New in draft 7.
	FormatDate Format = "date"

	// FormatEmail Internet email address, see RFC 5322, section 3.4.1.
	//
	// RFC 5322, section 3.4.1:
	//   http://tools.ietf.org/html/rfc5322#section-3.4.1
	FormatEmail Format = "email"

	// FormatIDNEmail the internationalized form of an Internet email address, see RFC 6531.
	//
	// RFC 6531:
	//   https://tools.ietf.org/html/rfc6531
	//
	// New in draft 7.
	FormatIDNEmail Format = "idn-email"

	// FormatHostname Internet host name, see RFC 1034, section 3.1.
	//
	// RFC 1034, section 3.1:
	//   http://tools.ietf.org/html/rfc1034#section-3.1
	FormatHostname Format = "hostname"

	// FormatIDNHostname an internationalized Internet host name, see RFC5890, section 2.3.2.3.
	//
	// RFC5890, section 2.3.2.3:
	//   https://tools.ietf.org/html/rfc5890#section-2.3.2.3
	//
	// New in draft 7.
	FormatIDNHostname Format = "idn-hostname"

	// FormatIPv4 IPv4 address, according to dotted-quad ABNF syntax as defined in RFC 2673, section 3.2.
	//
	// RFC 2673, section 3.2:
	//   http://tools.ietf.org/html/rfc2673#section-3.2
	FormatIPv4 Format = "ipv4"

	// FormatIPv6 IPv6 address, as defined in RFC 2373, section 2.2.
	//
	// RFC 2373, section 2.2:
	//   http://tools.ietf.org/html/rfc2373#section-2.2
	FormatIPv6 Format = "ipv6"

	// FormatURI a universal resource identifier (URI), according to RFC3986.
	//
	// Draft 4 only includes "uri", not "uri-reference". Therefore, there is some ambiguity around whether "uri" should accept relative paths.
	//
	// RFC3986:
	//   http://tools.ietf.org/html/rfc3986
	FormatURI Format = "uri"

	// FormatURIReference a URI Reference (either a URI or a relative-reference), according to RFC3986, section 4.1.
	//
	// RFC3986, section 4.1:
	//   http://tools.ietf.org/html/rfc3986#section-4.1
	//
	// New in draft 6.
	FormatURIReference Format = "uri-reference"

	// FormatIRI the internationalized equivalent of a “uri”, according to RFC3987.
	//
	// RFC3987:
	//   https://tools.ietf.org/html/rfc3987
	//
	// New in draft 7.
	FormatIRI Format = "iri"

	// FormatIRIReference the internationalized equivalent of a “uri-reference”, according to RFC3987.
	//
	// RFC3987:
	//   https://tools.ietf.org/html/rfc3987
	//
	// New in draft 7.
	FormatIRIReference Format = "iri-reference"

	// FormatURITemplate a URI Template (of any level) according to RFC6570. If you don’t already know what a URI Template is, you probably don’t need this value.
	//
	// RFC6570:
	//   https://tools.ietf.org/html/rfc6570
	//
	// New in draft 6.
	FormatURITemplate Format = "uri-template"

	// FormatJSONPointer a JSON Pointer, according to RFC6901.
	// There is more discussion on the use of JSON Pointer within JSON Schema in Structuring a complex schema.
	//
	// Note that this should be used only when the entire string contains only JSON Pointer content, e.g. /foo/bar.
	// JSON Pointer URI fragments, e.g. #/foo/bar/ should use "uri-reference".
	//
	// RFC6901:
	//   https://tools.ietf.org/html/rfc6901
	//
	// New in draft 6.
	FormatJSONPointer Format = "json-pointer"

	// FormatRelativeJSONPointer a relative JSON pointer.
	//
	// New in draft 7.
	FormatRelativeJSONPointer Format = "relative-json-pointer"

	// FormatRegex a regular expression, which should be valid according to the ECMA 262 dialect.
	//
	// ECMA 262:
	//   http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
	//
	// New in draft 7.
	FormatRegex Format = "regex"
)

The following is the list of built-in formats specified in the JSON Schema specification.

type Integer

type Integer struct {
	Value       int64
	Initialized bool
}

Integer is used for integral numbers.

func (*Integer) IsNil

func (i *Integer) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*Integer) MarshalJSONObject

func (i *Integer) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Integer) NKeys

func (*Integer) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*Integer) Reset

func (i *Integer) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Integer) UnmarshalJSONObject

func (i *Integer) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type IntegerStream

type IntegerStream chan *Integer

IntegerStream represents a stream encoding and decoding to Integer.

func (IntegerStream) MarshalStream

func (s IntegerStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (IntegerStream) UnmarshalStream

func (s IntegerStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Interfaces

type Interfaces []interface{}

Interfaces represents a slice of interface.

func (*Interfaces) IsNil

func (v *Interfaces) IsNil() bool

IsNil implements gojay.MarshalerJSONArray.

func (*Interfaces) MarshalJSONArray

func (v *Interfaces) MarshalJSONArray(enc *gojay.Encoder)

MarshalJSONArray implements gojay.MarshalerJSONArray.

func (*Interfaces) Reset

func (v *Interfaces) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Interfaces) UnmarshalJSONArray

func (v *Interfaces) UnmarshalJSONArray(dec *gojay.Decoder) error

UnmarshalJSONArray implements gojay.UnmarshalerJSONArray.

type InterfacesStream

type InterfacesStream chan *Interfaces

InterfacesStream represents a stream encoding and decoding to Interfaces.

func (InterfacesStream) MarshalStream

func (s InterfacesStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (InterfacesStream) UnmarshalStream

func (s InterfacesStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Items

type Items struct {
	Schemas     SchemaList
	HasMultiple bool
}

Items the elements of the array may be anything at all.

However, it’s often useful to validate the items of the array against some schema as well. This is done using the items, additionalItems, and contains keywords.

func (*Items) IsNil

func (i *Items) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*Items) MarshalJSONObject

func (i *Items) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Items) NKeys

func (i *Items) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*Items) Reset

func (i *Items) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Items) UnmarshalJSONObject

func (i *Items) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type ItemsStream

type ItemsStream chan *Items

ItemsStream represents a stream encoding and decoding to Items.

func (ItemsStream) MarshalStream

func (s ItemsStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (ItemsStream) UnmarshalStream

func (s ItemsStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type NameMap

type NameMap map[string][]string

NameMap represents a sttring key map of []string.

func (NameMap) IsNil

func (nm NameMap) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (NameMap) MarshalJSONObject

func (nm NameMap) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (NameMap) NKeys

func (NameMap) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (NameMap) Reset

func (nm NameMap) Reset()

Reset implements Pooler.

Reset reset fields.

func (NameMap) UnmarshalJSONObject

func (nm NameMap) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type NameMapStream

type NameMapStream chan *NameMap

NameMapStream represents a stream encoding and decoding to NameMap.

func (NameMapStream) MarshalStream

func (s NameMapStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (NameMapStream) UnmarshalStream

func (s NameMapStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Null

type Null struct {
	Value       json.RawMessage
	Initialized bool
}

Null is generally used to represent a missing value.

func (*Null) IsNil

func (n *Null) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*Null) MarshalJSONObject

func (n *Null) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Null) NKeys

func (*Null) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*Null) Reset

func (n *Null) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Null) UnmarshalJSONObject

func (n *Null) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type NullStream

type NullStream chan *Null

NullStream represents a stream encoding and decoding to Null.

func (NullStream) MarshalStream

func (s NullStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (NullStream) UnmarshalStream

func (s NullStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Number

type Number struct {
	Value       float64
	Initialized bool
}

Number used for any numeric type, either integers or floating point numbers.

func (*Number) IsNil

func (n *Number) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*Number) MarshalJSONObject

func (n *Number) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Number) NKeys

func (*Number) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*Number) Reset

func (n *Number) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Number) UnmarshalJSONObject

func (n *Number) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type NumberStream

type NumberStream chan *Number

NumberStream represents a stream encoding and decoding to Number.

func (NumberStream) MarshalStream

func (s NumberStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (NumberStream) UnmarshalStream

func (s NumberStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Object

type Object struct {
	Value       interface{}
	Initialized bool
}

Object is the mapping type in JSON. They map 'keys' to 'values'.

In JSON, the 'keys' must always be strings. Each of these pairs is conventionally referred to as a 'property'.

func (*Object) IsNil

func (o *Object) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*Object) MarshalJSONObject

func (o *Object) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Object) NKeys

func (*Object) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*Object) Reset

func (o *Object) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Object) UnmarshalJSONObject

func (o *Object) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type ObjectStream

type ObjectStream chan *Object

ObjectStream represents a stream encoding and decoding to Object.

func (ObjectStream) MarshalStream

func (s ObjectStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (ObjectStream) UnmarshalStream

func (s ObjectStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Pattern

type Pattern *regexp.Regexp

Pattern represents a use regular expressions to express constraints.

type PatternProperties

type PatternProperties map[*regexp.Regexp]*Schema

PatternProperties is the each property name of this object SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect. Each property value of this object MUST be a valid JSON Schema.

func (PatternProperties) IsNil

func (pp PatternProperties) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (PatternProperties) MarshalJSONObject

func (pp PatternProperties) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (PatternProperties) NKeys

func (PatternProperties) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (PatternProperties) Reset

func (pp PatternProperties) Reset()

Reset implements Pooler.

Reset reset fields.

func (PatternProperties) UnmarshalJSONObject

func (pp PatternProperties) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type PatternPropertiesStream

type PatternPropertiesStream chan *PatternProperties

PatternPropertiesStream represents a stream encoding and decoding to PatternProperties.

func (PatternPropertiesStream) MarshalStream

func (s PatternPropertiesStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (PatternPropertiesStream) UnmarshalStream

func (s PatternPropertiesStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Pooler

type Pooler interface {
	Reset()
}

Pooler represents a poolable interface.

type Properties

type Properties map[string]Schema

Properties (key-value pairs) on an object are defined using the properties keyword.

The value of properties is an object, where each key is the name of a property and each value is a JSON schema used to validate that property.

func (Properties) IsNil

func (p Properties) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (Properties) MarshalJSONObject

func (p Properties) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (Properties) NKeys

func (Properties) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (Properties) Reset

func (p Properties) Reset()

Reset implements Pooler.

Reset reset fields.

func (Properties) UnmarshalJSONObject

func (p Properties) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type PropertiesStream

type PropertiesStream chan *Properties

PropertiesStream represents a stream encoding and decoding to Properties.

func (PropertiesStream) MarshalStream

func (s PropertiesStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (PropertiesStream) UnmarshalStream

func (s PropertiesStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Schema

type Schema struct {
	Schema               string                     `json:"$schema"`
	ID                   string                     `json:"$id,omitempty"`
	Title                string                     `json:"title,omitempty"`
	Ref                  string                     `json:"$ref,omitempty"`
	Comment              string                     `json:"$comment,omitempty"`
	Description          string                     `json:"description,omitempty"`
	Default              interface{}                `json:"default,omitempty"`
	ReadOnly             bool                       `json:"readOnly,omitempty"`
	WriteOnly            bool                       `json:"writeOnly,omitempty"`
	Examples             SchemaList                 `json:"examples,omitempty"`
	MultipleOf           float64                    `json:"multipleOf,omitempty"` // exclusiveMinimum is 0
	Maximum              float64                    `json:"maximum,omitempty"`
	ExclusiveMaximum     bool                       `json:"exclusiveMaximum,omitempty"`
	Minimum              float64                    `json:"minimum,omitempty"`
	ExclusiveMinimum     bool                       `json:"exclusiveMinimum,omitempty"`
	MaxLength            int64                      `json:"maxLength,omitempty"` // minimum should be 0
	MinLength            int64                      `json:"minLength,omitempty"` // default should be 0
	Pattern              *regexp.Regexp             `json:"pattern,omitempty"`
	AdditionalItems      *AdditionalItems           `json:"additionalItems,omitempty"`
	Items                *Items                     `json:"items,omitempty"`
	MaxItems             int64                      `json:"maxItems,omitempty"`
	MinItems             int64                      `json:"minItems,omitempty"`
	UniqueItems          bool                       `json:"uniqueItems,omitempty"`
	Contains             *AdditionalProperties      `json:"contains,omitempty"`
	MaxProperties        int64                      `json:"maxProperties,omitempty"`
	MinProperties        int64                      `json:"minProperties,omitempty"`
	Required             StringArray                `json:"required,omitempty"`
	AdditionalProperties *AdditionalProperties      `json:"additionalProperties,omitempty"`
	Definitions          Definitions                `json:"definitions,omitempty"`
	Properties           Properties                 `json:"properties,omitempty"`
	PatternProperties    map[*regexp.Regexp]*Schema `json:"patternProperties,omitempty"`
	Dependencies         *DependencyMap             `json:"dependencies,omitempty"`
	PropertyNames        *Schema                    `json:"propertyNames,omitempty"`
	Const                *Const                     `json:"const,omitempty"`
	Enum                 Enum                       `json:"enum,omitempty"`
	Type                 Type                       `json:"type,omitempty"`
	Format               Format                     `json:"format,omitempty"`
	ContentMediaType     string                     `json:"contentMediaType,omitempty"`
	ContentEncoding      string                     `json:"contentEncoding,omitempty"`
	If                   *Schema                    `json:"if,omitempty"`
	Then                 *Schema                    `json:"then,omitempty"`
	Else                 *Schema                    `json:"else,omitempty"`
	AllOf                SchemaList                 `json:"allOf,omitempty"`
	AnyOf                SchemaList                 `json:"anyOf,omitempty"`
	OneOf                SchemaList                 `json:"oneOf,omitempty"`
	Not                  *Schema                    `json:"not,omitempty"`
}

Schema represents a JSON Schema.

func (*Schema) IsNil

func (d *Schema) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (Schema) MarshalJSON

func (d Schema) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Schema) MarshalJSONObject

func (d *Schema) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*Schema) NKeys

func (*Schema) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*Schema) Reset

func (d *Schema) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Schema) UnmarshalJSON

func (d *Schema) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Schema) UnmarshalJSONObject

func (d *Schema) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

func (Schema) Version

func (Schema) Version() DraftVersion

Version implements Schema.

type SchemaList

type SchemaList []*Schema

SchemaList list of Schema.

func (*SchemaList) IsNil

func (s *SchemaList) IsNil() bool

IsNil implements gojay.MarshalerJSONArray.

IsNil checks if instance is nil.

func (*SchemaList) MarshalJSONArray

func (s *SchemaList) MarshalJSONArray(enc *gojay.Encoder)

MarshalJSONArray implements gojay.MarshalerJSONArray.

func (*SchemaList) UnmarshalJSONArray

func (s *SchemaList) UnmarshalJSONArray(dec *gojay.Decoder) error

UnmarshalJSONArray implements gojay.UnmarshalerJSONArray.

type SchemaListStream

type SchemaListStream chan *SchemaList

Draft7ListStream represents a stream encoding and decoding to Draft7List.

func (SchemaListStream) MarshalStream

func (s SchemaListStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (SchemaListStream) UnmarshalStream

func (s SchemaListStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type SchemaMap

type SchemaMap map[string]*Schema

SchemaMap represents a sttring key map of Schema.

func (SchemaMap) IsNil

func (sm SchemaMap) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (SchemaMap) MarshalJSONObject

func (sm SchemaMap) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (SchemaMap) NKeys

func (SchemaMap) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (SchemaMap) Reset

func (sm SchemaMap) Reset()

Reset implements Pooler.

Reset reset fields.

func (SchemaMap) UnmarshalJSONObject

func (sm SchemaMap) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type SchemaMapStream

type SchemaMapStream chan *SchemaMap

SchemaMapStream represents a stream encoding and decoding to SchemaMap.

func (SchemaMapStream) MarshalStream

func (s SchemaMapStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (SchemaMapStream) UnmarshalStream

func (s SchemaMapStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type SchemaStream

type SchemaStream chan *Schema

SchemaStream represents a stream encoding and decoding to Draft7.

func (SchemaStream) MarshalStream

func (s SchemaStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (SchemaStream) UnmarshalStream

func (s SchemaStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Schemas

type Schemas []*Schema

Schemas list of Schema.

func (*Schemas) IsNil

func (ss *Schemas) IsNil() bool

IsNil implements gojay.MarshalerJSONArray.

IsNil checks if instance is nil

func (*Schemas) MarshalJSONArray

func (ss *Schemas) MarshalJSONArray(enc *gojay.Encoder)

MarshalJSONArray implements gojay.MarshalerJSONArray.

func (*Schemas) Reset

func (ss *Schemas) Reset()

Reset implements Pooler.

Reset reset fields.

func (*Schemas) UnmarshalJSONArray

func (ss *Schemas) UnmarshalJSONArray(dec *gojay.Decoder) error

UnmarshalJSONArray implements gojay.UnmarshalerJSONArray.

type SchemasStream

type SchemasStream chan *Schemas

SchemasStream represents a stream encoding and decoding to Schemas.

func (SchemasStream) MarshalStream

func (s SchemasStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (SchemasStream) UnmarshalStream

func (s SchemasStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type String

type String struct {
	Value       string
	Initialized bool
}

String is used for strings of text. It may contain Unicode characters.

func (*String) IsNil

func (s *String) IsNil() bool

IsNil implements gojay.MarshalerJSONObject.

IsNil checks if instance is nil.

func (*String) MarshalJSONObject

func (s *String) MarshalJSONObject(enc *gojay.Encoder)

MarshalJSONObject implements gojay.MarshalerJSONObject.

func (*String) NKeys

func (*String) NKeys() int

NKeys implements gojay.UnmarshalerJSONObject.

NKeys returns the number of keys to unmarshal.

func (*String) Reset

func (s *String) Reset()

Reset implements Pooler.

Reset reset fields.

func (*String) UnmarshalJSONObject

func (s *String) UnmarshalJSONObject(dec *gojay.Decoder, k string) error

UnmarshalJSONObject implements gojay.UnmarshalerJSONObject.

type StringArray

type StringArray []String

StringArray represents a String slice.

func (*StringArray) IsNil

func (sa *StringArray) IsNil() bool

IsNil implements gojay.MarshalerJSONArray.

IsNil checks if instance is nil

func (*StringArray) MarshalJSONArray

func (sa *StringArray) MarshalJSONArray(enc *gojay.Encoder)

MarshalJSONArray implements gojay.MarshalerJSONArray.

func (*StringArray) Reset

func (sa *StringArray) Reset()

Reset implements Pooler.

Reset reset fields.

func (*StringArray) UnmarshalJSONArray

func (sa *StringArray) UnmarshalJSONArray(dec *gojay.Decoder) error

UnmarshalJSONArray implements gojay.UnmarshalerJSONArray.

type StringArrayStream

type StringArrayStream chan *StringArray

StringArrayStream represents a stream encoding and decoding to StringArray.

func (StringArrayStream) MarshalStream

func (s StringArrayStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (StringArrayStream) UnmarshalStream

func (s StringArrayStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type StringStream

type StringStream chan *String

StringStream represents a stream encoding and decoding to String.

func (StringStream) MarshalStream

func (s StringStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (StringStream) UnmarshalStream

func (s StringStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

type Type

type Type int

Type represents a JSON Schema type keyword.

const (
	UnspecifiedType Type = iota
	ArrayType
	BooleanType
	IntegerType
	NullType
	NumberType
	ObjectType
	StringType
)

The list of Type keyword.

func TypeFromString

func TypeFromString(s string) Type

TypeFromString returs the Type from s.

func (Type) MarshalJSON

func (t Type) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (Type) String

func (t Type) String() string

String implements fmt.Stringer.

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type TypeName

type TypeName string

TypeName represents a Type keyword name.

const (
	UnspecifiedTypeName TypeName = "<unspecified>"
	ArrayTypeName       TypeName = "array"
	BooleanTypeName     TypeName = "boolean"
	IntegerTypeName     TypeName = "integer"
	NullTypeName        TypeName = "null"
	NumberTypeName      TypeName = "number"
	ObjectTypeName      TypeName = "object"
	StringTypeName      TypeName = "string"
)

The list of TypeName.

type Types

type Types []Type

Types represents a list of Type.

func (Types) Contains

func (ts Types) Contains(t Type) bool

Contains returns true if the list of types contains p.

func (*Types) IsNil

func (ts *Types) IsNil() bool

IsNil implements gojay.MarshalerJSONArray.

IsNil checks if instance is nil

func (Types) Len

func (ts Types) Len() int

Len implements sort.Interface.

func (Types) Less

func (ts Types) Less(i, j int) bool

Less implements sort.Interface.

func (*Types) MarshalJSONArray

func (ts *Types) MarshalJSONArray(enc *gojay.Encoder)

MarshalJSONArray implements gojay.MarshalerJSONArray.

func (*Types) Reset

func (ts *Types) Reset()

Reset implements Pooler.

Reset reset fields.

func (Types) Swap

func (ts Types) Swap(i, j int)

Swap implements sort.Interface.

func (*Types) UnmarshalJSON

func (ts *Types) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Types) UnmarshalJSONArray

func (ts *Types) UnmarshalJSONArray(dec *gojay.Decoder) error

UnmarshalJSONArray implements gojay.UnmarshalerJSONArray.

type TypesStream

type TypesStream chan *Types

TypesStream represents a stream encoding and decoding to Types.

func (TypesStream) MarshalStream

func (s TypesStream) MarshalStream(enc *gojay.StreamEncoder)

MarshalStream implements gojay.MarshalerStream.

func (TypesStream) UnmarshalStream

func (s TypesStream) UnmarshalStream(dec *gojay.StreamDecoder) error

UnmarshalStream implements gojay.UnmarshalerStream.

Directories

Path Synopsis
internal
lazyregexp
Package lazyregexp is a thin wrapper over regexp, allowing the use of global regexp variables without forcing them to be compiled at init.
Package lazyregexp is a thin wrapper over regexp, allowing the use of global regexp variables without forcing them to be compiled at init.
reflection
Package reflection wrapper of reflect package.
Package reflection wrapper of reflect package.
pkg
jsonpointer
Package jsonpointer an implementation of JSON Pointer for Go.
Package jsonpointer an implementation of JSON Pointer for Go.
jsonreference
Package jsonreference an implementation of JSON Reference for Go.
Package jsonreference an implementation of JSON Reference for Go.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL