summaryrefslogtreecommitdiff
path: root/vendor/github.com/goccy/go-json/option.go
diff options
context:
space:
mode:
authorLibravatar kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com>2022-09-28 18:30:40 +0100
committerLibravatar GitHub <noreply@github.com>2022-09-28 18:30:40 +0100
commita156188b3eb5cb3da44aa1b7452265f5fa38a607 (patch)
tree7097fa48d56fbabc7c2c8750b1f3bc9321d71c0f /vendor/github.com/goccy/go-json/option.go
parent[bugfix] Fix emphasis being added to emoji shortcodes with markdown parsing (... (diff)
downloadgotosocial-a156188b3eb5cb3da44aa1b7452265f5fa38a607.tar.xz
[chore] update dependencies, bump to Go 1.19.1 (#826)
* update dependencies, bump Go version to 1.19 * bump test image Go version * update golangci-lint * update gotosocial-drone-build * sign * linting, go fmt * update swagger docs * update swagger docs * whitespace * update contributing.md * fuckin whoopsie doopsie * linterino, linteroni * fix followrequest test not starting processor * fix other api/client tests not starting processor * fix remaining tests where processor not started * bump go-runners version * don't check last-webfingered-at, processor may have updated this * update swagger command * update bun to latest version * fix embed to work the same as before with new bun Signed-off-by: kim <grufwub@gmail.com> Co-authored-by: tsmethurst <tobi.smethurst@protonmail.com>
Diffstat (limited to 'vendor/github.com/goccy/go-json/option.go')
-rw-r--r--vendor/github.com/goccy/go-json/option.go72
1 files changed, 72 insertions, 0 deletions
diff --git a/vendor/github.com/goccy/go-json/option.go b/vendor/github.com/goccy/go-json/option.go
new file mode 100644
index 000000000..af400a452
--- /dev/null
+++ b/vendor/github.com/goccy/go-json/option.go
@@ -0,0 +1,72 @@
+package json
+
+import (
+ "io"
+
+ "github.com/goccy/go-json/internal/decoder"
+ "github.com/goccy/go-json/internal/encoder"
+)
+
+type EncodeOption = encoder.Option
+type EncodeOptionFunc func(*EncodeOption)
+
+// UnorderedMap doesn't sort when encoding map type.
+func UnorderedMap() EncodeOptionFunc {
+ return func(opt *EncodeOption) {
+ opt.Flag |= encoder.UnorderedMapOption
+ }
+}
+
+// DisableHTMLEscape disables escaping of HTML characters ( '&', '<', '>' ) when encoding string.
+func DisableHTMLEscape() EncodeOptionFunc {
+ return func(opt *EncodeOption) {
+ opt.Flag &= ^encoder.HTMLEscapeOption
+ }
+}
+
+// DisableNormalizeUTF8
+// By default, when encoding string, UTF8 characters in the range of 0x80 - 0xFF are processed by applying \ufffd for invalid code and escaping for \u2028 and \u2029.
+// This option disables this behaviour. You can expect faster speeds by applying this option, but be careful.
+// encoding/json implements here: https://github.com/golang/go/blob/6178d25fc0b28724b1b5aec2b1b74fc06d9294c7/src/encoding/json/encode.go#L1067-L1093.
+func DisableNormalizeUTF8() EncodeOptionFunc {
+ return func(opt *EncodeOption) {
+ opt.Flag &= ^encoder.NormalizeUTF8Option
+ }
+}
+
+// Debug outputs debug information when panic occurs during encoding.
+func Debug() EncodeOptionFunc {
+ return func(opt *EncodeOption) {
+ opt.Flag |= encoder.DebugOption
+ }
+}
+
+// DebugWith sets the destination to write debug messages.
+func DebugWith(w io.Writer) EncodeOptionFunc {
+ return func(opt *EncodeOption) {
+ opt.DebugOut = w
+ }
+}
+
+// Colorize add an identifier for coloring to the string of the encoded result.
+func Colorize(scheme *ColorScheme) EncodeOptionFunc {
+ return func(opt *EncodeOption) {
+ opt.Flag |= encoder.ColorizeOption
+ opt.ColorScheme = scheme
+ }
+}
+
+type DecodeOption = decoder.Option
+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 {
+ return func(opt *DecodeOption) {
+ opt.Flags |= decoder.FirstWinOption
+ }
+}