@@ -8,18 +8,21 @@ import (
8
8
type EncodeOption = encoder.Option
9
9
type EncodeOptionFunc func (* EncodeOption )
10
10
11
+ // UnorderedMap doesn't sort when encoding map type.
11
12
func UnorderedMap () EncodeOptionFunc {
12
13
return func (opt * EncodeOption ) {
13
14
opt .Flag |= encoder .UnorderedMapOption
14
15
}
15
16
}
16
17
18
+ // Debug outputs debug information when panic occurs during encoding.
17
19
func Debug () EncodeOptionFunc {
18
20
return func (opt * EncodeOption ) {
19
21
opt .Flag |= encoder .DebugOption
20
22
}
21
23
}
22
24
25
+ // Colorize add an identifier for coloring to the string of the encoded result.
23
26
func Colorize (scheme * ColorScheme ) EncodeOptionFunc {
24
27
return func (opt * EncodeOption ) {
25
28
opt .Flag |= encoder .ColorizeOption
@@ -30,6 +33,12 @@ func Colorize(scheme *ColorScheme) EncodeOptionFunc {
30
33
type DecodeOption = decoder.Option
31
34
type DecodeOptionFunc func (* DecodeOption )
32
35
36
+ // DecodeFieldPriorityFirstWin
37
+ // in the default behavior, go-json, like encoding/json,
38
+ // will reflect the result of the last evaluation when a field with the same name exists.
39
+ // This option allow you to change this behavior.
40
+ // this option reflects the result of the first evaluation if a field with the same name exists.
41
+ // This behavior has a performance advantage as it allows the subsequent strings to be skipped if all fields have been evaluated.
33
42
func DecodeFieldPriorityFirstWin () DecodeOptionFunc {
34
43
return func (opt * DecodeOption ) {
35
44
opt .Flag |= decoder .FirstWinOption
0 commit comments