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(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.
Array represents the encoding of a JSON Array
type Array struct {
// contains filtered or unexported fields
}
func (a *Array) Close()
Close encodes the end of the JSON Array
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.
Encoder is JSON encoder that supports construction of JSON values using methods.
type Encoder struct { Value // contains filtered or unexported fields }
func NewEncoder() *Encoder
NewEncoder returns a new JSON encoder
func (e Encoder) Bytes() []byte
Bytes returns the []byte slice of the JSON encoder
func (e Encoder) String() string
String returns the String output of the JSON encoder
Object represents the encoding of a JSON Object type
type Object struct {
// contains filtered or unexported fields
}
func (o *Object) Close()
Close encodes the end of the JSON Object
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.
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 (jv Value) Array() *Array
Array returns a new Array encoder
func (jv Value) Base64EncodeBytes(v []byte)
Base64EncodeBytes writes v as a base64 value in JSON string
func (jv Value) BigDecimal(v *big.Float)
BigDecimal encodes v as JSON value
func (jv Value) BigInteger(v *big.Int)
BigInteger encodes v as JSON value
func (jv Value) Boolean(v bool)
Boolean encodes v as a JSON boolean
func (jv Value) Byte(v int8)
Byte encodes v as a JSON number
func (jv Value) Double(v float64)
Double encodes v as a JSON number
func (jv Value) Float(v float32)
Float encodes v as a JSON number
func (jv Value) Integer(v int32)
Integer encodes v as a JSON number
func (jv Value) Long(v int64)
Long encodes v as a JSON number
func (jv Value) Null()
Null encodes a null JSON value
func (jv Value) Object() *Object
Object returns a new Object encoder
func (jv Value) Short(v int16)
Short encodes v as a JSON number
func (jv Value) String(v string)
String encodes v as a JSON string
func (jv Value) ULong(v uint64)
ULong encodes v as a JSON number
func (jv Value) Write(v []byte)
Write writes v directly to the JSON document