Documentation ¶
Index ¶
- func Marshal(v any, opts ...Option) ([]byte, error)
- func NewEncoder(w io.Writer) *json.Encoder
- func Unmarshal(data []byte, v any, opts ...Option) error
- func Write(w io.Writer, node Node, opts ...Option) error
- func WriteFile(filename string, node Node, perm os.FileMode, opts ...Option) error
- type Decoder
- type Node
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
Decoder wraps json.Decoder with options
func NewDecoder ¶
NewDecoder creates a decoder with reader and options
type Node ¶
type Node interface { // embed encoding.Node encoding.Node // Doc returns lead comments Doc() *encoding.CommentGroup // Comment returns line comments Comment() *encoding.CommentGroup // NumChild returns number of child nodes NumChild() int // ByIndex gets ith child node, key is empty if current node is not an object node // Panic if i out of range [0,NumChild) ByIndex(i int) (key string, node Node) // ByKey gets child node by key, nil returned if key not found ByKey(key string) Node // Value returns value of node as an interface Value() any // IsEmpty indicates whther node is empty IsEmpty() bool // contains filtered or unexported methods }
Node represents top-level json object
type Option ¶
type Option func(*options)
Option represents a function for setting options
func WithIndent ¶
WithIndent returns an option which with indent while outputing
func WithPrefix ¶
WithPrefix returns an option which with prefix while outputing
func WithSupportComment ¶
func WithSupportComment() Option
WithSupportComment returns an option which sets supportComment true
func WithSupportExtraComma ¶
func WithSupportExtraComma() Option
WithSupportExtraComma returns an option which sets extraComma true
func WithSupportUnquotedKey ¶
func WithSupportUnquotedKey() Option
WithSupportUnquotedKey returns an option which sets unquotedKey true
Click to show internal directories.
Click to hide internal directories.