jsonedit

package
v0.2.2 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: 6 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 jsonedit strictly decodes JSON edits onto live Go values without touching the edited value until the edit has succeeded.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeStrict

func DecodeStrict(data []byte, dst any) error

DecodeStrict decodes exactly one JSON value from data into dst, refusing unknown object fields and trailing data.

func Patch

func Patch[T any](cur *T, data []byte) (T, error)

Patch strictly decodes data onto a copy of *cur and returns the edited value, leaving *cur and everything it refers to unchanged whether or not the decode succeeds.

The decode runs on a clone of *cur whose exported pointers, maps, slices and interfaces are freshly allocated, so a decode that fails halfway cannot reach the live value. The result then starts from a plain copy of *cur and takes from the decoded clone only the exported fields the patch changed, so unexported fields, fields tagged `json:"-"` and the identity of every pointer, map and slice the patch left alone survive. A field the patch changed holds a freshly allocated value. A type that implements json.Unmarshaler or encoding.TextUnmarshaler is taken whole from the decoded clone, because its own decoding may set fields Patch cannot see.

Types

This section is empty.

Jump to

Keyboard shortcuts

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