jsonutil

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package jsonutil provides hardened JSON decoding helpers for untrusted input. Invariants: duplicate object keys are rejected; strict mode can reject unknown fields.

Index

Constants

View Source
const MaxSafeInt int64 = (1 << 53) - 1

MaxSafeInt is the maximum integer exactly representable in JSON (2^53 - 1).

Variables

This section is empty.

Functions

func DecodeNoDup

func DecodeNoDup[T any](jsonBytes []byte) (T, error)

DecodeNoDup decodes JSON into a Go struct while enforcing no duplicate keys. Unknown fields are allowed for forward compatibility.

func DecodeStrict

func DecodeStrict[T any](jsonBytes []byte) (T, error)

DecodeStrict decodes JSON into a Go struct while enforcing no duplicate keys and disallowing unknown fields.

func ValidateNoDuplicateKeys

func ValidateNoDuplicateKeys(data []byte) error

ValidateNoDuplicateKeys checks for duplicate object keys in JSON. Uses streaming because json.Unmarshal silently keeps only the last duplicate.

Types

This section is empty.

Jump to

Keyboard shortcuts

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