json

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2025 License: MIT Imports: 5 Imported by: 1

Documentation

Overview

Package json provides functions to facilitate dealing with JSON.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func From

func From[T any](r io.Reader, t T) (T, error)

From parses a io.Reader with JSON.

func IsValid added in v0.2.0

func IsValid[T string | []byte](data T) bool

IsValid checks if the given data is valid JSON.

func Reader

func Reader[T any](v T) io.Reader

Reader takes an input, marshal it to JSON and returns a io.Reader of it.

func Write

func Write(w http.ResponseWriter, data any) error

Write writes the given data as JSON.

Types

type ErrorReader

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

ErrorReader is a reader that always errors with the given error.

func (*ErrorReader) Read

func (r *ErrorReader) Read(_ []byte) (int, error)

Jump to

Keyboard shortcuts

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