...
1 package json
2
3 import (
4 "io"
5
6 "github.com/goccy/go-json/internal/decoder"
7 "github.com/goccy/go-json/internal/encoder"
8 )
9
10 type EncodeOption = encoder.Option
11 type EncodeOptionFunc func(*EncodeOption)
12
13
14 func UnorderedMap() EncodeOptionFunc {
15 return func(opt *EncodeOption) {
16 opt.Flag |= encoder.UnorderedMapOption
17 }
18 }
19
20
21 func DisableHTMLEscape() EncodeOptionFunc {
22 return func(opt *EncodeOption) {
23 opt.Flag &= ^encoder.HTMLEscapeOption
24 }
25 }
26
27
28
29
30
31 func DisableNormalizeUTF8() EncodeOptionFunc {
32 return func(opt *EncodeOption) {
33 opt.Flag &= ^encoder.NormalizeUTF8Option
34 }
35 }
36
37
38 func Debug() EncodeOptionFunc {
39 return func(opt *EncodeOption) {
40 opt.Flag |= encoder.DebugOption
41 }
42 }
43
44
45 func DebugWith(w io.Writer) EncodeOptionFunc {
46 return func(opt *EncodeOption) {
47 opt.DebugOut = w
48 }
49 }
50
51
52 func DebugDOT(w io.WriteCloser) EncodeOptionFunc {
53 return func(opt *EncodeOption) {
54 opt.DebugDOTOut = w
55 }
56 }
57
58
59 func Colorize(scheme *ColorScheme) EncodeOptionFunc {
60 return func(opt *EncodeOption) {
61 opt.Flag |= encoder.ColorizeOption
62 opt.ColorScheme = scheme
63 }
64 }
65
66 type DecodeOption = decoder.Option
67 type DecodeOptionFunc func(*DecodeOption)
68
69
70
71
72
73
74
75 func DecodeFieldPriorityFirstWin() DecodeOptionFunc {
76 return func(opt *DecodeOption) {
77 opt.Flags |= decoder.FirstWinOption
78 }
79 }
80
View as plain text