goccy.go 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // +build jwx_goccy
  2. package json
  3. import (
  4. "io"
  5. "github.com/goccy/go-json"
  6. )
  7. type Decoder = json.Decoder
  8. type Delim = json.Delim
  9. type Encoder = json.Encoder
  10. type Marshaler = json.Marshaler
  11. type Number = json.Number
  12. type RawMessage = json.RawMessage
  13. type Unmarshaler = json.Unmarshaler
  14. func Engine() string {
  15. return "github.com/goccy/go-json"
  16. }
  17. // NewDecoder respects the values specified in DecoderSettings,
  18. // and creates a Decoder that has certain features turned on/off
  19. func NewDecoder(r io.Reader) *json.Decoder {
  20. dec := json.NewDecoder(r)
  21. muGlobalConfig.RLock()
  22. if useNumber {
  23. dec.UseNumber()
  24. }
  25. muGlobalConfig.RUnlock()
  26. return dec
  27. }
  28. // NewEncoder is just a proxy for "encoding/json".NewEncoder
  29. func NewEncoder(w io.Writer) *json.Encoder {
  30. return json.NewEncoder(w)
  31. }
  32. // Marshal is just a proxy for "encoding/json".Marshal
  33. func Marshal(v interface{}) ([]byte, error) {
  34. return json.Marshal(v)
  35. }
  36. // MarshalIndent is just a proxy for "encoding/json".MarshalIndent
  37. func MarshalIndent(v interface{}, prefix, indent string) ([]byte, error) {
  38. return json.MarshalIndent(v, prefix, indent)
  39. }