consensus/utils/json.go
DataHoarder e321374da1
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Update to version v3.7.0, remove replace directives from go.mod
2024-04-14 10:13:19 +02:00

29 lines
726 B
Go

package utils
import (
gojson "git.gammaspectra.live/P2Pool/go-json"
"io"
)
var JsonEncodeOptions = []gojson.EncodeOptionFunc{gojson.DisableHTMLEscape(), gojson.DisableNormalizeUTF8()}
func MarshalJSON(val any) ([]byte, error) {
return gojson.MarshalWithOption(val, JsonEncodeOptions...)
}
func MarshalJSONIndent(val any, indent string) ([]byte, error) {
return gojson.MarshalIndentWithOption(val, "", indent, JsonEncodeOptions...)
}
func UnmarshalJSON(data []byte, val any) error {
return gojson.UnmarshalWithOption(data, val)
}
func NewJSONEncoder(writer io.Writer) *gojson.Encoder {
return gojson.NewEncoder(writer)
}
func NewJSONDecoder(reader io.Reader) *gojson.Decoder {
return gojson.NewDecoder(reader)
}