strictjson

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package strictjson provides an exact JSON decoding boundary for durable authority. It supplements encoding/json with recursive duplicate rejection and case-sensitive field matching; DisallowUnknownFields alone is case-insensitive and therefore cannot prevent alias overwrites.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeArray

func DecodeArray(value []byte, maxBytes int, destination any) error

DecodeArray is DecodeObject's top-level-array counterpart. It exists for narrowly gated legacy formats whose historical root was an array.

func DecodeObject

func DecodeObject(value []byte, maxBytes int, destination any) error

DecodeObject decodes exactly one JSON object into destination. Object field names must exactly match their Go JSON tags at every recursively typed struct boundary; duplicate, unknown, case-aliased, and trailing data fail.

func DecodeRawObject

func DecodeRawObject(
	value []byte,
	maxBytes int,
	allowed map[string]struct{},
) (map[string]json.RawMessage, error)

DecodeRawObject returns an exact object whose keys are constrained by allowed. Values remain raw but are still recursively checked for duplicate object fields and the document must contain exactly one value.

func ValidateUniqueArray

func ValidateUniqueArray(value []byte, maxBytes int) error

ValidateUniqueArray verifies one bounded array and rejects duplicate object keys recursively.

func ValidateUniqueObject

func ValidateUniqueObject(value []byte, maxBytes int) error

ValidateUniqueObject verifies one bounded object and rejects duplicate keys recursively, including objects nested inside arrays.

Types

This section is empty.

Jump to

Keyboard shortcuts

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