Documentation ¶
Overview ¶
Package unjson uses reflection to marshal/unmarshal JSON from njson.Node input It's NOT a 'drop-in' replacement for "encoding/json".
Index ¶
- func Marshal(x interface{}) ([]byte, error)
- func MarshalTo(out []byte, x interface{}) ([]byte, error)
- func Unmarshal(data []byte, x interface{}) error
- func UnmarshalFromNode(n njson.Node, x interface{}) error
- func UnmarshalFromString(s string, x interface{}) (err error)
- type Decoder
- type Encoder
- type FieldParser
- type LineDecoder
- type LineEncoder
- type Omiter
- type Options
- type RawString
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func UnmarshalFromNode ¶
func UnmarshalFromString ¶
Types ¶
type Decoder ¶
type Decoder interface { Decode(x interface{}, n njson.Node) error // contains filtered or unexported methods }
Decoder is a type specific decoder
type Encoder ¶
type Encoder interface { Encode(out []byte, x interface{}) ([]byte, error) // contains filtered or unexported methods }
Encoder is a type specific encoder
type FieldParser ¶
type FieldParser interface {
// contains filtered or unexported methods
}
func NewFieldParser ¶
func NewFieldParser(key string, omitempty bool) FieldParser
type LineDecoder ¶
type LineDecoder struct { Decoder // Use a specific type decoder // contains filtered or unexported fields }
LineDecoder decodes from a newline delimited JSON stream. (http://ndjson.org/)
func NewLineDecoder ¶
func NewLineDecoder(r io.Reader) *LineDecoder
NewLineDecoder creates a new LineDecoder
func (*LineDecoder) Decode ¶
func (d *LineDecoder) Decode(x interface{}) (err error)
Decode decodes the next JSON line in the stream to x
type LineEncoder ¶
type LineEncoder struct { Encoder // contains filtered or unexported fields }
LineEncoder encodes to a newline delimited JSON stream. (http://ndjson.org/)
func NewLineEncoder ¶
func NewLineEncoder(w io.Writer) *LineEncoder
NewLineEncoder creates a new LineEncoder
func (*LineEncoder) Encode ¶
func (e *LineEncoder) Encode(x interface{}) (err error)
Encode encodes a value to a new JSON line on the stream.
type Options ¶
type Options struct { Tag string OmitEmpty bool // FieldParser // If nil DefaultFieldParser is used OmitMethod string // Method name for checking if a value is empty HTML bool // Escape HTML-safe AllowNaN bool // Allow NaN values for numbers AllowInf bool // Allow ±Inf values for numbers }
func DefaultOptions ¶
func DefaultOptions() Options
Click to show internal directories.
Click to hide internal directories.