jsondto

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2020 License: Unlicense Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UnmarshalJSON

func UnmarshalJSON(d []byte) (val json.Marshaler, err error)

UnmarshalJSON unmarshals d into a value-type.

errors:

*SyntaxError
*MultipleValuesError

Types

type Array

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

Array represents a JSON-array.

func (*Array) Append

func (a *Array) Append(v ...json.Marshaler) error

Append adds v to a.

errors:

*UnsupportedTypeError

func (*Array) At

func (a *Array) At(i int) json.Marshaler

At returns the value at index i.

func (*Array) Cap

func (a *Array) Cap() int

Cap returns the capacity of a.

func (*Array) Clear

func (a *Array) Clear()

Clear removes all values.

func (*Array) Insert

func (a *Array) Insert(i int, v json.Marshaler) error

Insert adds v at i.

errors:

*BoundsError
*UnsupportedTypeError

func (*Array) Len

func (a *Array) Len() int

Len returns the number of values.

func (*Array) MarshalJSON

func (a *Array) MarshalJSON() ([]byte, error)

MarshalJSON returns a JSON-array.

func (*Array) Remove

func (a *Array) Remove(i int) error

Remove removes the element at index i.

errors:

*BoundsError

func (*Array) Reserve

func (a *Array) Reserve(c int)

Reserve ensures a capacity of, at least, c.

func (*Array) Set

func (a *Array) Set(i int, v json.Marshaler) error

Set sets the value at index i.

errors:

*BoundsError
*UnsupportedTypeError

func (*Array) Trim

func (a *Array) Trim()

Trim reduces the capacity to len.

func (*Array) UnmarshalJSON

func (a *Array) UnmarshalJSON(d []byte) (err error)

UnmarshalJSON unmarshals a JSON-array into a.

errors:

*MultipleValuesError
*SyntaxError
*UnmarshalTypeError

type Bool

type Bool bool

Bool represents a bool value.

func (Bool) MarshalJSON

func (v Bool) MarshalJSON() ([]byte, error)

type BoundsError

type BoundsError struct {
	Index int
}

BoundsError indicates an array-access out-of-bounds.

func (*BoundsError) Error

func (err *BoundsError) Error() string

type Float

type Float float64

Float represents a floating-point value.

func (Float) MarshalJSON

func (v Float) MarshalJSON() ([]byte, error)

type Int

type Int int64

Int represents an integer value.

func (Int) MarshalJSON

func (v Int) MarshalJSON() ([]byte, error)

type MultipleValuesError

type MultipleValuesError struct {
	Data []byte
}

MultipleValuesError indicates multiple top-level JSON-values in the input-data.

func (*MultipleValuesError) Error

func (err *MultipleValuesError) Error() string

type Null

type Null struct{}

Null represents a null value.

func (Null) MarshalJSON

func (v Null) MarshalJSON() ([]byte, error)

type Object

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

Object represents a JSON-object.

func (*Object) Clear

func (o *Object) Clear()

Clear removes all kv-pairs.

func (*Object) Delete

func (o *Object) Delete(k String)

Delete removes a kv-pair.

func (*Object) Get

func (o *Object) Get(k String) json.Marshaler

Get returns a kv-pair.

func (*Object) Len

func (o *Object) Len() int

Len returns the number of kv-pairs.

func (*Object) MarshalJSON

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

MarshalJSON returns a JSON-object.

func (*Object) Put

func (o *Object) Put(k String, v json.Marshaler) error

Put adds a kv-pair.

errors:

*UnsupportedTypeError

func (*Object) Range

func (o *Object) Range(f func(k String, v json.Marshaler) bool)

Range iterates over o, until f==false.

func (*Object) UnmarshalJSON

func (o *Object) UnmarshalJSON(d []byte) (err error)

UnmarshalJSON unmarshals a JSON-object into o.

errors:

*MultipleValuesError
*SyntaxError
*UnmarshalTypeError

type String

type String string

String represents a string value.

func (String) MarshalJSON

func (v String) MarshalJSON() ([]byte, error)

type SyntaxError

type SyntaxError struct {
	Err *json.SyntaxError
}

SyntaxError indicates a syntax-error in the input-data.

func (*SyntaxError) Error

func (err *SyntaxError) Error() string

func (*SyntaxError) Unwrap

func (err *SyntaxError) Unwrap() error

type UnmarshalContainer

type UnmarshalContainer struct {
	Val json.Marshaler
	Err error
}

UnmarshalContainer wraps UnmarshalJSON, for use with json.Decoder.

func (*UnmarshalContainer) UnmarshalJSON

func (c *UnmarshalContainer) UnmarshalJSON(d []byte) error

type UnmarshalTypeError

type UnmarshalTypeError struct {
	Value string // json-value-type: null,bool,int,float,string,object,array
	Type  string // go-type: Object,Array
}

UnmarshalTypeError indicates a JSON-value, inappropriate for a specific go-type.

func (*UnmarshalTypeError) Error

func (err *UnmarshalTypeError) Error() string

type UnsupportedTypeError

type UnsupportedTypeError struct {
	T reflect.Type
}

UnsupportedTypeError indicates an illegal type.

func (*UnsupportedTypeError) Error

func (err *UnsupportedTypeError) Error() string

Jump to

Keyboard shortcuts

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