jsonstrict

package
v0.144.8 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2026 License: Apache-2.0 Imports: 8 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 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