jsonstrict

package
v0.70.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package jsonstrict provides target-aware JSON key validation shared by transport and persisted event decoders.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckNoDuplicateKeysFor

func CheckNoDuplicateKeysFor(data []byte, target reflect.Type) error

CheckNoDuplicateKeysFor rejects repeated object keys. When an object is decoded into a struct, keys are compared with encoding/json's case-folding rules so two spellings cannot silently target the same field.

func CheckNoDuplicateKeysForSchema added in v0.60.2

func CheckNoDuplicateKeysForSchema(data []byte, schema reflect.Type) error

CheckNoDuplicateKeysForSchema traverses an explicit typed schema, folding only known field names. Unknown case-distinct metadata keys remain independent; exact duplicate keys are still rejected at every depth. Custom unmarshalers remain opaque: callers must supply a method-free schema to inspect their fields.

func FoldName

func FoldName(name string) string

FoldName folds a JSON name the same way encoding/json matches struct fields.

func FoldRune

func FoldRune(r rune) rune

FoldRune returns the smallest rune in r's simple case-folding orbit.

func ObjectFields

func ObjectFields(target reflect.Type) (map[string]reflect.Type, bool)

ObjectFields returns the fields encoding/json decodes an object into, keyed by their folded JSON name.

func ValidateUnicode added in v0.67.0

func ValidateUnicode(body []byte) error

ValidateUnicode refuses malformed UTF-8 and escaped unpaired surrogates. encoding/json otherwise silently substitutes the Unicode replacement character.

Types

This section is empty.

Jump to

Keyboard shortcuts

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