tractor.dev/toolkit-go@v0.0.0-20241010005851-214d91207d07/duplex/codec/json.go (about)

     1  package codec
     2  
     3  import (
     4  	"encoding/json"
     5  	"io"
     6  )
     7  
     8  // JSONCodec provides a codec API for the standard library JSON encoder and decoder.
     9  type JSONCodec struct{}
    10  
    11  // Encoder returns a JSON encoder
    12  func (c JSONCodec) Encoder(w io.Writer) Encoder {
    13  	return json.NewEncoder(w)
    14  }
    15  
    16  // Decoder returns a JSON decoder
    17  func (c JSONCodec) Decoder(r io.Reader) Decoder {
    18  	return json.NewDecoder(r)
    19  }