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 ¶
Validate applies DefaultLimits and rejects malformed JSON, duplicate decoded object keys, trailing data, and inputs that exceed a structural bound.
func ValidateWithLimits ¶
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.