Documentation
¶
Overview ¶
Package schemajson parses immutable, ordered JSON documents without losing native schema syntax, number precision, or escaped UTF-16 code units.
Index ¶
- Constants
- func Fold[R any](k Kind, cs KindCases[R]) R
- func KindEqual(a, b Kind) bool
- func KindEqualWith(a, b Kind, ov KindEqOverrides) bool
- func KindName(kind Kind) string
- type Array
- type Boolean
- type Document
- type Error
- type Kind
- type KindCases
- type KindEqOverrides
- type Limits
- type Member
- type Node
- func (n Node) ElementCount() int
- func (n Node) Elements() []Node
- func (n Node) Kind() Kind
- func (n Node) Lookup(key string) (Node, bool)
- func (n Node) LookupText(key value.Text) (Node, bool)
- func (n Node) MemberCount() int
- func (n Node) Members() []Member
- func (n Node) Raw() string
- func (n Node) Text() (value.Text, bool)
- type Null
- type Number
- type Object
- type String
Constants ¶
const DefaultBytes = 16 * 1024 * 1024
const DefaultDepth = 256
const DefaultNodes = 1000000
Variables ¶
This section is empty.
Functions ¶
func KindEqualWith ¶
func KindEqualWith(a, b Kind, ov KindEqOverrides) bool
KindEqualWith reports structural equality of a and b under ov.
Types ¶
type Document ¶
type Document struct {
// contains filtered or unexported fields
}
func Parse ¶
Parse rejects duplicate decoded keys at every nesting level. It preserves the original bytes for unmodified export and never resolves references or accesses the network/filesystem. This is syntax ingestion, not schema validity.
func (Document) At ¶
At looks up an existing node by a JSON Pointer. Empty means the document root. Array indexes are canonical nonnegative decimals; '-' is not a lookup.
func (Document) Replace ¶
Replace returns a new document, changing only the selected node's source span. Other bytes (including unrelated native constraints) remain untouched. It replaces existing values, not member names or missing members. This is the lossless editing primitive, not a claim of schema-level compatibility.
type Error ¶
type KindCases ¶
type KindCases[R any] struct { Object func() R Array func() R String func() R Number func() R Boolean func() R Null func() R }
KindCases selects one handler per Kind variant for Fold.
type KindEqOverrides ¶
type KindEqOverrides struct {
Object func(x, y Object) (eq, handled bool)
Array func(x, y Array) (eq, handled bool)
String func(x, y String) (eq, handled bool)
Number func(x, y Number) (eq, handled bool)
Boolean func(x, y Boolean) (eq, handled bool)
Null func(x, y Null) (eq, handled bool)
}
KindEqOverrides carries optional per-variant hooks for KindEqualWith. A hook returning handled=false falls through to the derived comparison.
type Limits ¶
Limits protect ingestion separately from predicate evaluation. Zero values select defaults; an explicit positive value configures each resource cap.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node retains an exact source slice. Its data cannot be mutated through public accessors, including ordered object members and array elements.
func (Node) ElementCount ¶
ElementCount reports array cardinality before a defensive Elements copy.
func (Node) MemberCount ¶
MemberCount reports object cardinality without copying the immutable member slice, allowing allocation preflight before Members.