gosds

package module
v0.0.0-...-ee8c7c3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 9 Imported by: 0

README

Go Self Describing Structure

TODO

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFinalized             = errors.New("node is finalized, can't be edited")
	ErrNoOpenedArrayOrObject = errors.New("can't close object or array because there is no opened node")
	ErrMissingKey            = errors.New("can't create value without key")
	ErrDoubleKey             = errors.New("already have a key for next value")
	ErrUnusedKey             = errors.New("key for value is unused")
)

Functions

func Marshal

func Marshal(node Node) (string, error)

func MarshalEncode

func MarshalEncode(node Node, output Encoder)

func MarshalWrite

func MarshalWrite(node Node, output Writer) error

func UnmarshalDecode

func UnmarshalDecode(_ Decoder) error

Types

type Accepted

type Accepted interface {
	~string | ~int | ~int64 | ~int32 | ~int16 | ~int8 | ~uint | ~uint64 | ~uint32 | ~uint16 | ~uint8 | ~float64 | ~float32 | ~bool //nolint:lll
}

type Array

type Array interface {
	Node
	Indexed
	AppendValue(value any)
}

func NewArray

func NewArray() Array

func NewArrayWithCapacity

func NewArrayWithCapacity(capacity int) Array

type Builder

type Builder interface {
	AddKey(key string) error
	AddValue(val any) error
	AddKeyValue(key string, val any) error
	StartObject() error
	StartObjectWithCapacity(capacity int) error
	StartArray() error
	StartArrayWithCapacity(capacity int) error
	EndObjectOrArray() error
	Build() Root
}

func NewBuilder

func NewBuilder() Builder

type BuilderSonic

type BuilderSonic interface {
	OnNull() error
	OnBool(v bool) error
	OnString(v string) error
	OnInt64(_ int64, n json.Number) error
	OnFloat64(_ float64, n json.Number) error
	OnObjectBegin(capacity int) error
	OnObjectKey(key string) error
	OnObjectEnd() error
	OnArrayBegin(capacity int) error
	OnArrayEnd() error
	Build() Root
}

func NewBuilderSonic

func NewBuilderSonic() BuilderSonic

type Castable

type Castable interface {
	IsKeyed() bool
	IsIndexed() bool
	IsObject() bool
	IsArray() bool
	IsRoot() bool
	AsKeyed() Keyed
	AsIndexed() Indexed
	AsObject() Object
	AsArray() Array
	AsRoot() Root
}

type Container

type Container interface {
	Get() any
	Set(val any)
	Remove()
	Primitive() any
	Exist() bool
}

type Decoder

type Decoder interface {
	More() bool
	Token() (json.Token, error)
}

type EncoderBool

type EncoderBool interface {
	Bool(v bool)
}

type EncoderFloat

type EncoderFloat interface {
	Float64(n float64)
	Float32(n float32)
}

type EncoderInt

type EncoderInt interface {
	Int(n int)
	Int64(n int64)
	Int32(n int32)
	Int16(n int16)
	Int8(n int8)
}

type EncoderRaw

type EncoderRaw interface {
	RawByte(c byte)
	RawString(s string)
}

type EncoderString

type EncoderString interface {
	String(s string)
}

type EncoderUint

type EncoderUint interface {
	Uint(n uint)
	Uint64(n uint64)
	Uint32(n uint32)
	Uint16(n uint16)
	Uint8(n uint8)
}

type Indexed

type Indexed interface {
	NodeAtIndex(index int) Node
	ValueAtIndex(index int) any
	SetValueAtIndex(index int, value any)
	RemoveValueAtIndex(index int)
	Size() int
	PrimitiveArray() []any
}

type Keyed

type Keyed interface {
	NodeForKey(key string) Node
	ValueForKey(key string) (any, bool)
	SetValueForKey(key string, value any)
	RemoveValueForKey(key string)
	Keys() []string
	PrimitiveObject() map[string]any
}

type Marshaler

type Marshaler interface {
	MarshalEncode(Encoder)
	MarshalWrite(Writer) error
}

type Node

type Node interface {
	Parented
	Container
	Castable
	Marshaler
}

type Number

type Number = json.Number

type Object

type Object interface {
	Node
	Keyed
	Indexed
}

func NewObject

func NewObject() Object

func NewObjectWithCapacity

func NewObjectWithCapacity(capacity int) Object

type Parented

type Parented interface {
	Root() Root
	Parent() Node
	Index() int
	Key() string
}

type Reader

type Reader = io.Reader

type Root

type Root interface {
	Parented
	Container
	Castable
	Marshaler
}

func NewRoot

func NewRoot(val any) Root

func Unmarshal

func Unmarshal(jstr string) (Root, error)

func UnmarshalRead

func UnmarshalRead(input Reader) (Root, error)

type Value

type Value interface {
	Node
	Container
}

type Writer

type Writer = io.Writer

Jump to

Keyboard shortcuts

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