jsonkeys

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package jsonkeys implements per-key JSON pointer merge used by adapters that need to own a subset of keys inside a shared JSON (or JSONC) config file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeObject

func DecodeObject(data []byte) (map[string]any, error)

DecodeObject unmarshals JSON object bytes into a map, preserving numbers as json.Number rather than coercing to float64. The merge promises to preserve FOREIGN keys verbatim, but float64 silently rounds any integer larger than 2^53 (snowflake ids, nanosecond timestamps) on re-marshal. json.Number keeps the literal digits and re-marshals exactly. nil/empty input yields an empty map.

func DecodeYAML

func DecodeYAML(yml []byte) (map[string]any, error)

DecodeYAML parses YAML (e.g. component frontmatter) into a map, preserving integer precision beyond 2^53. A plain yaml.Unmarshal into interface{} decodes every number as float64, silently rounding a large integer (snowflake id, nanosecond timestamp) — and since yaml.Marshal then re-emits the rounded value, the corruption is persisted on render and on source write-back. This routes YAML→JSON (which keeps the integer literal), decodes with UseNumber, then converts each json.Number to int64 (or float64) so yaml.Marshal re-emits a bare integer. Empty/null input yields an empty map; a non-mapping document is an error (frontmatter must be a mapping).

func MergeKeys

func MergeKeys(existing, ours map[string]any, ownedPointers []string) (map[string]any, []string, []string)

MergeKeys merges ours into existing, removing ownedPointers that are no longer in ours. Returns the merged map plus diagnostic lists.

kept: pointers from ownedPointers that are still present in ours. removed: pointers from ownedPointers that are absent from ours and were deleted from existing.

JSON pointer syntax: leading "/", "/" separated path segments. RFC 6901 escapes ("~0" for "~", "~1" for "/") are supported.

Types

This section is empty.

Jump to

Keyboard shortcuts

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