Help us shape the future of Go! Take the 2026 Go Developer Survey

jsonino

package module
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2025 License: MIT Imports: 11 Imported by: 1

README

jsonino

Go Reference

JSON utility package including JSON Schema and type utils.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseAnyTime

func ParseAnyTime(date string) time.Time

Types

type ArrayScheme

type ArrayScheme struct {
	TypeName string  `json:"type"`
	Items    *Schema `json:"items,omitempty"`
	MaxItems *int    `json:"maxItems,omitempty"`
	MinItems *int    `json:"minItems,omitempty"`
}

func (*ArrayScheme) SampleJSON

func (s *ArrayScheme) SampleJSON() any

func (*ArrayScheme) Type

func (s *ArrayScheme) Type() string

func (*ArrayScheme) Validate

func (s *ArrayScheme) Validate(buf []byte) bool

type Node

type Node struct {
	Type        string
	BoolValue   *bool
	StringValue *string
	NumberValue *float64
	ArrayValue  []*Node
	ObjectValue map[string]*Node
}

type NumberScheme

type NumberScheme struct {
	TypeName     string   `json:"type"`
	Description  string   `json:"description,omitempty"`
	Value        *float64 `json:"value,omitempty"`
	Max          *float64 `json:"maximum,omitempty"`
	ExclusiveMax *float64 `json:"exclusiveMaximum,omitempty"`
	Min          *float64 `json:"minimum,omitempty"`
	ExclusiveMin *float64 `json:"exclusiveMinimum,omitempty"`
	MultipleOf   *int     `json:"multipleOf,omitempty"`
}

func (*NumberScheme) SampleJSON

func (s *NumberScheme) SampleJSON() any

func (*NumberScheme) Type

func (s *NumberScheme) Type() string

func (*NumberScheme) Validate

func (s *NumberScheme) Validate(buf []byte) bool

type ObjectScheme

type ObjectScheme struct {
	TypeName   string             `json:"type"`
	Properties map[string]*Schema `json:"properties,omitempty"`
	Required   []string           `json:"required,omitempty"`
	Order      []string           `json:"order,omitempty"`
}

func (*ObjectScheme) SampleJSON

func (s *ObjectScheme) SampleJSON() any

func (*ObjectScheme) Type

func (s *ObjectScheme) Type() string

func (*ObjectScheme) Validate

func (s *ObjectScheme) Validate(buf []byte) bool

type OneOfSchema

type OneOfSchema struct {
	OneOf []*Schema `json:"oneOf,omitempty"`
}

func (*OneOfSchema) SampleJSON

func (s *OneOfSchema) SampleJSON() any

func (*OneOfSchema) Type

func (s *OneOfSchema) Type() string

func (*OneOfSchema) Validate

func (s *OneOfSchema) Validate(buf []byte) bool

type OneOrMore

type OneOrMore[T any] struct {
	One  *T
	More []*T
}

func (*OneOrMore[T]) Do

func (o *OneOrMore[T]) Do(f func(t *T) bool) bool

func (*OneOrMore[T]) Iter

func (o *OneOrMore[T]) Iter() chan<- *T

func (*OneOrMore[T]) MarshalJSON

func (o *OneOrMore[T]) MarshalJSON() ([]byte, error)

func (*OneOrMore[T]) MarshalYAML

func (o *OneOrMore[T]) MarshalYAML() ([]byte, error)

func (*OneOrMore[T]) UnmarshalJSON

func (o *OneOrMore[T]) UnmarshalJSON(data []byte) error

func (*OneOrMore[T]) UnmarshalYAML

func (o *OneOrMore[T]) UnmarshalYAML(data []byte) error

type PathResolver

type PathResolver func(path string) Validator

type RefScheme

type RefScheme struct {
	Ref string `json:"$ref"`
}

func (*RefScheme) SampleJSON

func (s *RefScheme) SampleJSON() any

func (*RefScheme) Type

func (s *RefScheme) Type() string

func (*RefScheme) Validate

func (s *RefScheme) Validate(buf []byte) bool

type Regexp

type Regexp struct {
	Pattern string
	// contains filtered or unexported fields
}

func (*Regexp) MarshalJSON

func (o *Regexp) MarshalJSON() ([]byte, error)

func (*Regexp) MarshalYAML

func (o *Regexp) MarshalYAML() ([]byte, error)

func (*Regexp) Regexp

func (o *Regexp) Regexp() *regexp.Regexp

func (*Regexp) UnmarshalJSON

func (o *Regexp) UnmarshalJSON(data []byte) (err error)

func (*Regexp) UnmarshalYAML

func (o *Regexp) UnmarshalYAML(data []byte) (err error)

type SampleGenerator

type SampleGenerator interface {
	SampleJSON() any
	// contains filtered or unexported methods
}

type Schema

type Schema struct {
	TypeName string     `json:"type"`
	Format   string     `json:"format,omitempty"`
	This     schemaNode `json:"-"`
}

func NewSchema

func NewSchema(buf []byte) (*Schema, error)

func SchemaFrom

func SchemaFrom(v any) (*Schema, error)

func (*Schema) MarshalJSON

func (s *Schema) MarshalJSON() ([]byte, error)

func (*Schema) MarshalYAML

func (s *Schema) MarshalYAML() ([]byte, error)

func (*Schema) Parse

func (s *Schema) Parse(pr PathResolver, buf []byte) (*Node, error)

func (*Schema) SampleJSON

func (s *Schema) SampleJSON() any

func (*Schema) Type

func (s *Schema) Type() string

func (*Schema) UnmarshalJSON

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

func (*Schema) Validate

func (s *Schema) Validate(buf []byte) bool

func (*Schema) ValidateNode

func (s *Schema) ValidateNode(pr PathResolver, node *Node) bool

type StringScheme

type StringScheme struct {
	TypeName    string  `json:"type"`
	Description string  `json:"description,omitempty"`
	Value       *string `json:"value,omitempty"`
	MaxLength   *int    `json:"maxLength,omitempty"`
	MinLength   *int    `json:"minLength,omitempty"`
	Pattern     *string `json:"pattern,omitempty"`
	// contains filtered or unexported fields
}

func (*StringScheme) SampleJSON

func (s *StringScheme) SampleJSON() any

func (*StringScheme) Type

func (s *StringScheme) Type() string

func (*StringScheme) Validate

func (s *StringScheme) Validate(buf []byte) bool

type UnixTime

type UnixTime struct {
	// contains filtered or unexported fields
}

func (UnixTime) MarshalJSON

func (o UnixTime) MarshalJSON() ([]byte, error)

func (UnixTime) MarshalYAML

func (o UnixTime) MarshalYAML() ([]byte, error)

func (UnixTime) Time

func (o UnixTime) Time() time.Time

func (*UnixTime) UnmarshalJSON

func (o *UnixTime) UnmarshalJSON(data []byte) error

func (*UnixTime) UnmarshalYAML

func (o *UnixTime) UnmarshalYAML(data []byte) error

type Validator

type Validator interface {
	Type() string
	Validate(buf []byte) bool
}

Jump to

Keyboard shortcuts

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