github.com/lestrrat-go/jwx/v2@v2.0.21/internal/json/goccy.go (about)

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