strictjson

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 3 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 performs bounded, duplicate-safe RFC 8259 structural validation before callers decode JSON into typed values.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Validate

func Validate(source []byte) error

Validate applies DefaultLimits and rejects malformed JSON, duplicate decoded object keys, trailing data, and inputs that exceed a structural bound.

func ValidateWithLimits

func ValidateWithLimits(source []byte, configured Limits) error

ValidateWithLimits applies caller-provided structural limits. Zero-valued fields inherit their defaults, which makes Limits{} equivalent to Validate.

Types

type Limits

type Limits struct {
	MaxInputBytes    int
	MaxDepth         int
	MaxTokens        int
	MaxObjectMembers int
	MaxArrayElements int
	MaxKeyBytes      int
	MaxTotalKeyBytes int64
	MaxWorkBytes     int64
}

Limits bounds both the accepted JSON shape and the work needed to validate it. A zero field selects that field's value from DefaultLimits. Negative values are invalid.

MaxDepth counts nested arrays and objects. MaxTokens counts every JSON value and every object key. Object-member and array-element limits apply to each individual container. Byte limits count decoded UTF-8 key bytes. MaxWorkBytes charges input bytes, tokens, decoded-key validation, and bounded duplicate-detection work.

func DefaultLimits

func DefaultLimits() Limits

DefaultLimits returns conservative process-level bounds. The array and token defaults intentionally admit manifests containing at least 100,000 frame records while keeping hostile inputs finite.

Jump to

Keyboard shortcuts

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