jsonedit

package
v2.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: Apache-2.0 Imports: 4 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 edits JSON objects while preserving key order and untouched values, so aitk can update tool config files without reformatting the user's settings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Object

type Object struct {
	// contains filtered or unexported fields
}

Object is a JSON object with ordered keys. Values stay raw until edited.

func Parse

func Parse(b []byte) (*Object, error)

Parse decodes an object. Empty input yields an empty object. JSONC line comments are rejected.

func (*Object) Bytes

func (o *Object) Bytes() []byte

Bytes renders the object indented with two spaces and a trailing newline.

func (*Object) Child

func (o *Object) Child(k string) (*Object, error)

Child returns the object at key (creating it when absent).

func (*Object) Delete added in v2.5.0

func (o *Object) Delete(k string)

Delete removes key, keeping the order of the others.

func (*Object) Get

func (o *Object) Get(k string) (json.RawMessage, bool)

Get returns the raw value at key.

func (*Object) Len added in v2.5.0

func (o *Object) Len() int

Len is the number of keys.

func (*Object) MarshalJSON

func (o *Object) MarshalJSON() ([]byte, error)

MarshalJSON renders the object with keys in order.

func (*Object) Set

func (o *Object) Set(k string, v any) error

Set stores a value (marshaled) at key, keeping the key's position if it exists.

Jump to

Keyboard shortcuts

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