stdlib.go 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //go:build !jwx_goccy
  2. // +build !jwx_goccy
  3. package json
  4. import (
  5. "encoding/json"
  6. "io"
  7. )
  8. type Decoder = json.Decoder
  9. type Delim = json.Delim
  10. type Encoder = json.Encoder
  11. type Marshaler = json.Marshaler
  12. type Number = json.Number
  13. type RawMessage = json.RawMessage
  14. type Unmarshaler = json.Unmarshaler
  15. func Engine() string {
  16. return "encoding/json"
  17. }
  18. // NewDecoder respects the values specified in DecoderSettings,
  19. // and creates a Decoder that has certain features turned on/off
  20. func NewDecoder(r io.Reader) *json.Decoder {
  21. dec := json.NewDecoder(r)
  22. muGlobalConfig.RLock()
  23. if useNumber {
  24. dec.UseNumber()
  25. }
  26. muGlobalConfig.RUnlock()
  27. return dec
  28. }
  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. }