...

Package json

import "github.com/aws/smithy-go/encoding/json"
Overview
Index

Overview ▾

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 a decoder body. This function is useful while deserializing a JSON body with additional unknown information that should be discarded.

type Array

Array represents the encoding of a JSON Array

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

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

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

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

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

Object represents the encoding of a JSON Object type

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

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

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

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

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) ULong

func (jv Value) ULong(v uint64)

ULong encodes v as a JSON number

func (Value) Write

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

Write writes v directly to the JSON document