mirror of https://github.com/goccy/go-json.git
Add document for options
This commit is contained in:
parent
5c39787fbd
commit
8a3ef38852
|
@ -8,18 +8,21 @@ import (
|
||||||
type EncodeOption = encoder.Option
|
type EncodeOption = encoder.Option
|
||||||
type EncodeOptionFunc func(*EncodeOption)
|
type EncodeOptionFunc func(*EncodeOption)
|
||||||
|
|
||||||
|
// UnorderedMap doesn't sort when encoding map type.
|
||||||
func UnorderedMap() EncodeOptionFunc {
|
func UnorderedMap() EncodeOptionFunc {
|
||||||
return func(opt *EncodeOption) {
|
return func(opt *EncodeOption) {
|
||||||
opt.Flag |= encoder.UnorderedMapOption
|
opt.Flag |= encoder.UnorderedMapOption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debug outputs debug information when panic occurs during encoding.
|
||||||
func Debug() EncodeOptionFunc {
|
func Debug() EncodeOptionFunc {
|
||||||
return func(opt *EncodeOption) {
|
return func(opt *EncodeOption) {
|
||||||
opt.Flag |= encoder.DebugOption
|
opt.Flag |= encoder.DebugOption
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Colorize add an identifier for coloring to the string of the encoded result.
|
||||||
func Colorize(scheme *ColorScheme) EncodeOptionFunc {
|
func Colorize(scheme *ColorScheme) EncodeOptionFunc {
|
||||||
return func(opt *EncodeOption) {
|
return func(opt *EncodeOption) {
|
||||||
opt.Flag |= encoder.ColorizeOption
|
opt.Flag |= encoder.ColorizeOption
|
||||||
|
@ -30,6 +33,12 @@ func Colorize(scheme *ColorScheme) EncodeOptionFunc {
|
||||||
type DecodeOption = decoder.Option
|
type DecodeOption = decoder.Option
|
||||||
type DecodeOptionFunc func(*DecodeOption)
|
type DecodeOptionFunc func(*DecodeOption)
|
||||||
|
|
||||||
|
// DecodeFieldPriorityFirstWin
|
||||||
|
// in the default behavior, go-json, like encoding/json,
|
||||||
|
// will reflect the result of the last evaluation when a field with the same name exists.
|
||||||
|
// This option allow you to change this behavior.
|
||||||
|
// this option reflects the result of the first evaluation if a field with the same name exists.
|
||||||
|
// This behavior has a performance advantage as it allows the subsequent strings to be skipped if all fields have been evaluated.
|
||||||
func DecodeFieldPriorityFirstWin() DecodeOptionFunc {
|
func DecodeFieldPriorityFirstWin() DecodeOptionFunc {
|
||||||
return func(opt *DecodeOption) {
|
return func(opt *DecodeOption) {
|
||||||
opt.Flag |= decoder.FirstWinOption
|
opt.Flag |= decoder.FirstWinOption
|
||||||
|
|
Loading…
Reference in New Issue