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