json

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2020 License: Apache-2.0 Imports: 9 Imported by: 741

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CollectUnknownField

func CollectUnknownField(decoder *json.Decoder) ([]byte, error)

CollectUnknownField grabs the contents of unknown fields from the decoder body and returns them as a byte slice. This is useful for skipping unknown fields without completely discarding them.

func DiscardUnknownField

func DiscardUnknownField(decoder *json.Decoder) error

DiscardUnknownField discards unknown fields from decoder body. This function is useful while deserializing json body with additional unknown information that should be discarded.

Types

type Array

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

Array represent the encoding of a JSON Array

func (*Array) Close

func (a *Array) Close()

Close encodes the end of the JSON Array

func (*Array) Value

func (a *Array) Value() Value

Value adds a new element to the JSON Array. Returns a Value type that is used to encode the array element.

type Encoder

type Encoder struct {
	Value
	// contains filtered or unexported fields
}

Encoder is JSON encoder that supports construction of JSON values using methods.

func NewEncoder

func NewEncoder() *Encoder

NewEncoder returns a new JSON encoder

func (Encoder) Bytes

func (e Encoder) Bytes() []byte

Bytes returns the []byte slice of the JSON encoder

func (Encoder) String

func (e Encoder) String() string

String returns the String output of the JSON encoder

type Object

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

Object represents the encoding of a JSON Object type

func (*Object) Close

func (o *Object) Close()

Close encodes the end of the JSON Object

func (*Object) Key

func (o *Object) Key(name string) Value

Key adds the given named key to the JSON object. Returns a Value encoder that should be used to encode a JSON value type.

type Value

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

Value represents a JSON Value type JSON Value types: Object, Array, String, Number, Boolean, and Null

func (Value) Array

func (jv Value) Array() *Array

Array returns a new Array encoder

func (Value) Base64EncodeBytes

func (jv Value) Base64EncodeBytes(v []byte)

Base64EncodeBytes writes v as a base64 value in JSON string

func (Value) BigDecimal

func (jv Value) BigDecimal(v *big.Float)

BigDecimal encodes v as JSON value

func (Value) BigInteger

func (jv Value) BigInteger(v *big.Int)

BigInteger encodes v as JSON value

func (Value) Boolean

func (jv Value) Boolean(v bool)

Boolean encodes v as a JSON boolean

func (Value) Byte

func (jv Value) Byte(v int8)

Byte encodes v as a JSON number

func (Value) Double

func (jv Value) Double(v float64)

Double encodes v as a JSON number

func (Value) Float

func (jv Value) Float(v float32)

Float encodes v as a JSON number

func (Value) Integer

func (jv Value) Integer(v int32)

Integer encodes v as a JSON number

func (Value) Long

func (jv Value) Long(v int64)

Long encodes v as a JSON number

func (Value) Null

func (jv Value) Null()

Null encodes a null JSON value

func (Value) Object

func (jv Value) Object() *Object

Object returns a new Object encoder

func (Value) Short

func (jv Value) Short(v int16)

Short encodes v as a JSON number

func (Value) String

func (jv Value) String(v string)

String encodes v as a JSON string

func (Value) Write

func (jv Value) Write(v []byte)

Write writes v directly to the JSON document

Jump to

Keyboard shortcuts

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