strictjson

package
v0.1.0-c02.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: Apache-2.0 Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package strictjson provides bounded structural validation for untrusted JSON.

Index

Constants

View Source
const (
	// MaxDocumentBytes bounds a single Kubernetes or adapter response.
	MaxDocumentBytes = 8 << 20
)

Variables

View Source
var (
	ErrInvalid   = errors.New("invalid JSON document")
	ErrDuplicate = errors.New("duplicate JSON object field")
	ErrTooLarge  = errors.New("JSON document exceeds size limit")
)

Functions

func Decode

func Decode(data []byte, destination any) error

Decode validates one document and then decodes it while retaining integer precision when the destination contains interface values.

func DecodeExact

func DecodeExact(data []byte, destination any) error

DecodeExact validates one document and rejects fields that are not present in the destination type. Use it for closed external protocols whose JSON Schema declares additionalProperties=false. Kubernetes objects intentionally use Decode so forward-compatible fields remain covered by the state digest.

func Read

func Read(reader io.Reader) ([]byte, error)

Read validates and returns exactly one bounded JSON document. Error text never reflects the untrusted input.

func Validate

func Validate(data []byte) error

Validate rejects malformed, duplicate-key, deeply nested, and trailing JSON.

Types

This section is empty.

Jump to

Keyboard shortcuts

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