Documentation
¶
Index ¶
Constants ¶
View Source
const ( ErrUnmarshalProtoJSONFailed = "failed to unmarshal proto JSON: %v" ErrReadBodyFailed = "failed to read body: %v" )
Variables ¶
View Source
var ( ErrCodeReadBodyFailed string ErrCodeInvalidProtoMessage string ErrCodeUnmarshalProtoJSONFailed string )
View Source
var ( ErrInvalidProtoMessage = errors.New("invalid proto message") ErrNilMarshalOptions = errors.New("nil marshal options") )
Functions ¶
func UnmarshalByReflection ¶ added in v0.12.4
func UnmarshalByReflection( reader io.Reader, dest interface{}, unmarshalOptions *protojson.UnmarshalOptions, ) error
UnmarshalByReflection decodes JSON from io.Reader into a destination, handling nested proto.Message fields.
Parameters:
- r: The io.Reader to read JSON data from
- dest: The destination to decode the JSON data into
- unmarshalOptions: Options for unmarshalling proto messages (optional, can be nil)
Returns:
- error: The error if any
Types ¶
type Decoder ¶
type Decoder struct {
// contains filtered or unexported fields
}
func NewDecoder ¶
func NewDecoder() *Decoder
NewDecoder creates a new Decoder instance
Returns:
- *Decoder: The decoder instance
func (Decoder) Decode ¶
Decode decodes the JSON body from an any value and stores it in the destination
Parameters:
- body: The body to decode
- dest: The destination to store the decoded body
Returns:
- error: The error if any
func (Decoder) DecodeReader ¶ added in v0.12.2
DecodeReader decodes a JSON body from a reader into a destination
Parameters:
- reader: The io.Reader to read the body from
- dest: The destination to decode the body into
Returns:
- error: The error if any
func (Decoder) DecodeRequest ¶ added in v0.12.2
DecodeRequest decodes a JSON body from an HTTP request into a destination
Parameters:
- request: The HTTP request to read the body from
- dest: The destination to decode the body into
Returns:
- error: The error if any
Click to show internal directories.
Click to hide internal directories.