jsonvalue

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package jsonvalue preserves numeric tokens for domain operations that require exact JSON numbers, while retaining JSON v2's strict input validation.

Index

Constants

This section is empty.

Variables

View Source
var Numbers = json.WithUnmarshalers(json.UnmarshalFromFunc(func(decoder *jsontext.Decoder, value *any) error {
	if decoder.PeekKind() != '0' {
		return errors.ErrUnsupported
	}
	token, err := decoder.ReadToken()
	if err != nil {
		return err
	}
	*value = jsonv1.Number(token.String())
	return nil
}))

Numbers keeps the original numeric token instead of rounding it to float64. Non-number values use the ordinary JSON v2 decoder and its default semantics. JSON v2 has no Number type; json.Number is retained as the interoperable exact numeric value consumed by schema validation and other numeric domain operations.

Functions

func Snapshot added in v1.3.0

func Snapshot(value any) (any, error)

Snapshot returns the private, float64-number representation of a default JSON v2 marshal/unmarshal round trip. Ordinary JSON-shaped values can be copied without encoding; all other values retain the standard library path.

Types

This section is empty.

Jump to

Keyboard shortcuts

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