json

package
v0.12.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Decoder added in v0.11.2

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder struct

func NewDecoder added in v0.11.2

func NewDecoder(
	mode *goflagsmode.Flag,
) *Decoder

NewDecoder creates a new JSON decoder

Parameters:

  • mode: The flag mode

Returns:

  • *Decoder: The default decoder

func (Decoder) Decode added in v0.11.2

func (d Decoder) Decode(
	body interface{},
	dest interface{},
) error

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

func (d Decoder) DecodeReader(
	reader io.Reader,
	dest interface{},
) error

DecodeReader decodes the JSON body and stores it in the destination

Parameters:

  • reader: The reader to read the body from
  • dest: The destination to store the decoded body

Returns:

  • error: The error if any

func (Decoder) DecodeRequest added in v0.12.2

func (d Decoder) DecodeRequest(
	r *http.Request,
	dest interface{},
) error

DecodeRequest decodes the JSON request body and stores it in the destination

Parameters:

  • request: The HTTP request
  • dest: The destination to store the decoded body

Returns:

  • error: The error if any

type StreamDecoder added in v0.11.2

type StreamDecoder struct {
	// contains filtered or unexported fields
}

StreamDecoder is the JSON decoder struct

func NewStreamDecoder added in v0.11.2

func NewStreamDecoder(
	mode *goflagsmode.Flag,
) *StreamDecoder

NewStreamDecoder creates a new JSON decoder

Parameters:

  • mode: The flag mode
  • responsesHandler: The HTTP handler to handle errors

Returns:

  • *StreamDecoder: The default decoder

func (StreamDecoder) Decode added in v0.11.2

func (s StreamDecoder) Decode(
	body interface{},
	dest interface{},
) error

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 (StreamDecoder) DecodeReader added in v0.12.2

func (s StreamDecoder) DecodeReader(
	reader io.Reader,
	dest interface{},
) error

DecodeReader decodes a JSON body from a reader into a destination

Parameters:

  • reader: The reader to read the body from
  • dest: The destination to store the decoded body

Returns:

  • error: The error if any

func (StreamDecoder) DecodeRequest added in v0.12.2

func (s StreamDecoder) DecodeRequest(
	r *http.Request,
	dest interface{},
) error

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 store the decoded body

Returns:

  • error: The error if any

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL