jsonw

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

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

Go to latest
Published: Mar 25, 2020 License: BSD-3-Clause Imports: 8 Imported by: 250

README

Json Wrapper for Go

Documentation

Index

Constants

View Source
const JSONDoubleQuotationMark = byte('"')
View Source
const JSONEscape = byte('\\')
View Source
const JSONLeftCurlyBracket = byte('{')
View Source
const JSONLeftSquareBracket = byte('[')
View Source
const JSONRightCurlyBracket = byte('}')
View Source
const JSONRightSquareBracket = byte(']')

Variables

This section is empty.

Functions

func Canonicalize

func Canonicalize(in []byte) ([]byte, error)

func EnsureMaxDepth

func EnsureMaxDepth(unsafeRawReader *bufio.Reader, maxDepth int) error

ensureMaxDepth returns an error if raw represents a valid JSON string whose deserialization's maximum depth exceeds maxDepth. If raw represents an invalid JSON string with a prefix that is a valid JSON prefix whose depth exceeds maxDepth, an error will be returned as well). See https://github.com/golang/go/blob/master/src/encoding/json/decode.go#L96. Otherwise, behavior is undefined and an error may or may not be returned. See the spec at https://json.org.

func EnsureMaxDepthBytesDefault

func EnsureMaxDepthBytesDefault(unsafeRaw []byte) error

func EnsureMaxDepthDefault

func EnsureMaxDepthDefault(unsafeRawReader *bufio.Reader) error

Types

type DepthError

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

func (DepthError) Error

func (d DepthError) Error() string

type Error

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

func (Error) Error

func (e Error) Error() string

type Wrapper

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

func NewArray

func NewArray(l int) *Wrapper

func NewBool

func NewBool(b bool) *Wrapper

func NewDictionary

func NewDictionary() *Wrapper

func NewFloat64

func NewFloat64(f float64) *Wrapper

func NewInt

func NewInt(i int) *Wrapper

func NewInt64

func NewInt64(i int64) *Wrapper

func NewNil

func NewNil() *Wrapper

func NewObjectWrapper

func NewObjectWrapper(i interface{}) (*Wrapper, error)

NewObjectWrapper takes a Go object that has JSON field struct annotations and inserts it into a JSON wrapper. The serialization happens eagerly, and the object is copied into the wrapper, so that subsequent updates to the object will not be reflected in the Wrapper.

func NewString

func NewString(s string) *Wrapper

func NewUint64

func NewUint64(u uint64) *Wrapper

func NewWrapper

func NewWrapper(i interface{}) (rd *Wrapper)

func Unmarshal

func Unmarshal(unsafeRaw []byte) (*Wrapper, error)

func UnmarshalWithMaxDepth

func UnmarshalWithMaxDepth(unsafeRaw []byte, maxDepth int) (*Wrapper, error)

func WrapperFromObject

func WrapperFromObject(obj interface{}) (*Wrapper, error)

func (*Wrapper) AccessPath

func (i *Wrapper) AccessPath() string

func (*Wrapper) AssertEqAtPath

func (w *Wrapper) AssertEqAtPath(path string, obj *Wrapper, errp *error)

func (*Wrapper) AtIndex

func (rd *Wrapper) AtIndex(i int) *Wrapper

func (*Wrapper) AtKey

func (rd *Wrapper) AtKey(s string) *Wrapper

func (*Wrapper) AtPath

func (w *Wrapper) AtPath(path string) (ret *Wrapper)

func (*Wrapper) AtPathGetInt

func (w *Wrapper) AtPathGetInt(path string) (ret int, ok bool)

func (*Wrapper) DeleteKey

func (w *Wrapper) DeleteKey(s string) error

func (*Wrapper) DeleteValueAtPath

func (w *Wrapper) DeleteValueAtPath(path string) error

func (*Wrapper) Error

func (i *Wrapper) Error() (e error)

func (*Wrapper) GetBool

func (rd *Wrapper) GetBool() (ret bool, err error)

func (*Wrapper) GetBoolVoid

func (w *Wrapper) GetBoolVoid(bp *bool, errp *error)

func (*Wrapper) GetBytes

func (rd *Wrapper) GetBytes() (ret []byte, err error)

func (*Wrapper) GetBytesVoid

func (w *Wrapper) GetBytesVoid(bp *[]byte, errp *error)

func (*Wrapper) GetData

func (i *Wrapper) GetData() (dat interface{}, err error)

func (*Wrapper) GetDataOrNil

func (i *Wrapper) GetDataOrNil() interface{}

func (*Wrapper) GetDataVoid

func (i *Wrapper) GetDataVoid(dp *interface{}, ep *error)

func (*Wrapper) GetFloat

func (rd *Wrapper) GetFloat() (ret float64, err error)

func (*Wrapper) GetFloatVoid

func (w *Wrapper) GetFloatVoid(fp *float64, errp *error)

func (*Wrapper) GetInt

func (rd *Wrapper) GetInt() (i int, err error)

func (*Wrapper) GetInt64

func (rd *Wrapper) GetInt64() (ret int64, err error)

func (*Wrapper) GetInt64Void

func (w *Wrapper) GetInt64Void(ip *int64, errp *error)

func (*Wrapper) GetIntVoid

func (w *Wrapper) GetIntVoid(ip *int, errp *error)

func (*Wrapper) GetInterface

func (rd *Wrapper) GetInterface() (v interface{}, err error)

func (*Wrapper) GetString

func (rd *Wrapper) GetString() (ret string, err error)

func (*Wrapper) GetStringVoid

func (w *Wrapper) GetStringVoid(sp *string, errp *error)

func (*Wrapper) GetUint

func (rd *Wrapper) GetUint() (u uint, err error)

func (*Wrapper) GetUint64

func (rd *Wrapper) GetUint64() (ret uint64, err error)

func (*Wrapper) GetUint64Void

func (w *Wrapper) GetUint64Void(ip *uint64, errp *error)

func (*Wrapper) GetUintVoid

func (w *Wrapper) GetUintVoid(ip *uint, errp *error)

func (*Wrapper) IsNil

func (rd *Wrapper) IsNil() bool

func (*Wrapper) IsOk

func (i *Wrapper) IsOk() bool

func (*Wrapper) Keys

func (i *Wrapper) Keys() (v []string, err error)

func (*Wrapper) Len

func (rd *Wrapper) Len() (ret int, err error)

func (*Wrapper) Marshal

func (w *Wrapper) Marshal() ([]byte, error)

func (*Wrapper) MarshalJSON

func (w *Wrapper) MarshalJSON() ([]byte, error)

MarshalJSON makes Wrapper satisfy the encoding/json.Marshaler interface.

func (*Wrapper) MarshalPretty

func (w *Wrapper) MarshalPretty() string

func (*Wrapper) MarshalToDebug

func (w *Wrapper) MarshalToDebug() string

func (*Wrapper) NewError

func (w *Wrapper) NewError(format string, a ...interface{}) *Error

func (*Wrapper) SetIndex

func (w *Wrapper) SetIndex(i int, val *Wrapper) error

func (*Wrapper) SetKey

func (w *Wrapper) SetKey(s string, val *Wrapper) error

func (*Wrapper) SetValueAtPath

func (w *Wrapper) SetValueAtPath(path string, value *Wrapper) error

func (*Wrapper) ToArray

func (rd *Wrapper) ToArray() (out *Wrapper, e error)

func (*Wrapper) ToDictionary

func (rd *Wrapper) ToDictionary() (out *Wrapper, e error)

func (*Wrapper) UnmarshalAgain

func (w *Wrapper) UnmarshalAgain(i interface{}) (err error)

Jump to

Keyboard shortcuts

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