allow invalid utf8 characters when marshalizing json responses

This commit is contained in:
Gani Georgiev committed 2026-08-24 14:13:53 +03:00
1 parent 50f5f83ace
commit 756b326bfa
9 files changed
+57 -20

No files matched your search

+5 -1
View File
@@ -1,6 +1,7 @@
package picker
import (
"encoding/json/jsontext"
"encoding/json/v2"
"strings"
@@ -29,9 +30,12 @@ func Pick(data any, rawFields string) (any, error) {
// implementations are invoked, and then convert it back to a plain
// json value that we can further operate on.
//
// Note that invalid UTF8 characters are mangled for compatibility
// with earlier versions and to prevent unnecessery causing an error.
//
// @todo research other approaches to avoid the double serialization
// ---
encoded, err := json.Marshal(data)
encoded, err := json.Marshal(data, jsontext.AllowInvalidUTF8(true))
if err != nil {
return nil, err
}