json

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: Apache-2.0 Imports: 11 Imported by: 298

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(b []byte, vs structform.Visitor) error

func ParseReader

func ParseReader(in io.Reader, vs structform.Visitor) (int64, error)

func ParseString

func ParseString(str string, vs structform.Visitor) error

Types

type Decoder

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

func NewBytesDecoder

func NewBytesDecoder(b []byte, vs structform.Visitor) *Decoder

func NewDecoder

func NewDecoder(in io.Reader, buffer int, vs structform.Visitor) *Decoder

func (*Decoder) Next

func (dec *Decoder) Next() error

type Parser

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

func NewParser

func NewParser(vs structform.Visitor) *Parser

func (*Parser) Parse

func (p *Parser) Parse(b []byte) error

func (*Parser) ParseString

func (p *Parser) ParseString(str string) error

func (*Parser) Write

func (p *Parser) Write(b []byte) (int, error)

type Visitor

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

Visitor implements the structform.Visitor interface, json encoding the structure being visited

func NewVisitor

func NewVisitor(out io.Writer) *Visitor

func (*Visitor) OnArrayFinished

func (vs *Visitor) OnArrayFinished() error

func (*Visitor) OnArrayStart

func (vs *Visitor) OnArrayStart(_ int, _ structform.BaseType) error

func (*Visitor) OnBool

func (vs *Visitor) OnBool(b bool) error

func (*Visitor) OnByte

func (vs *Visitor) OnByte(b byte) error

func (*Visitor) OnFloat32

func (vs *Visitor) OnFloat32(f float32) error

func (*Visitor) OnFloat64

func (vs *Visitor) OnFloat64(f float64) error

func (*Visitor) OnInt

func (vs *Visitor) OnInt(i int) error

func (*Visitor) OnInt16

func (vs *Visitor) OnInt16(i int16) error

func (*Visitor) OnInt32

func (vs *Visitor) OnInt32(i int32) error

func (*Visitor) OnInt64

func (vs *Visitor) OnInt64(i int64) error

func (*Visitor) OnInt8

func (vs *Visitor) OnInt8(i int8) error

func (*Visitor) OnKey

func (vs *Visitor) OnKey(s string) error

func (*Visitor) OnKeyRef

func (vs *Visitor) OnKeyRef(s []byte) error

func (*Visitor) OnNil

func (vs *Visitor) OnNil() error

func (*Visitor) OnObjectFinished

func (vs *Visitor) OnObjectFinished() error

func (*Visitor) OnObjectStart

func (vs *Visitor) OnObjectStart(_ int, _ structform.BaseType) error

func (*Visitor) OnString

func (vs *Visitor) OnString(s string) error

func (*Visitor) OnStringRef

func (vs *Visitor) OnStringRef(s []byte) error

func (*Visitor) OnUint

func (vs *Visitor) OnUint(u uint) error

func (*Visitor) OnUint16

func (vs *Visitor) OnUint16(u uint16) error

func (*Visitor) OnUint32

func (vs *Visitor) OnUint32(u uint32) error

func (*Visitor) OnUint64

func (vs *Visitor) OnUint64(u uint64) error

func (*Visitor) OnUint8

func (vs *Visitor) OnUint8(u uint8) error

func (*Visitor) SetEscapeHTML added in v0.0.4

func (v *Visitor) SetEscapeHTML(b bool)

func (*Visitor) SetExplicitRadixPoint added in v0.0.12

func (v *Visitor) SetExplicitRadixPoint(b bool)

SetExplicitRadixPoint configures whether the visitor encodes floating point values with an explicit radix point. By default, equiv to SetExplicitRadixPoint(false), the radix point will be skipped if it is not needed. e.g. 1.0 to 1 instead of 1.0, 100000000 to 1e+8 instead of 1.0e+8. If true is passed, the encoded number will always contain a radix point, in either decimal form or scientific notation. This may be useful to signal the type of the number to a json parser.

func (*Visitor) SetIgnoreInvalidFloat added in v0.0.8

func (v *Visitor) SetIgnoreInvalidFloat(b bool)

SetIgnoreInvalidFloat configures how the visitor handles undefined floating point values like NaN or Inf. By default the visitor will error. This behavior is similar to setting SetIgnoreInvalidFloat(false). If true is passed, then invalid floating point values will be replaces with the `null` symbol.

Jump to

Keyboard shortcuts

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