jsondoc

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 6 Imported by: ? 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 jsondoc holds a JSON object in memory so a pipeline can read and change it without scanning or copying its text on every operation.

Reads return gjson results and paths follow gjson's syntax, so code written against gjson works unchanged. Plain dotted paths are answered straight from the parsed tree; any path that uses gjson's richer syntax (wildcards, queries, modifiers, escapes) is answered by gjson over the document's text, which is produced once and kept until the next change.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Doc

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

Doc is a JSON object. It is not safe for concurrent use.

func Parse

func Parse(s string) (*Doc, error)

Parse reads a JSON object. Numbers keep their original text.

func (*Doc) Delete

func (d *Doc) Delete(path string)

Delete removes path if it exists.

func (*Doc) Get

func (d *Doc) Get(path string) gjson.Result

Get returns the value at path as a gjson result.

func (*Doc) GetString

func (d *Doc) GetString(path string) string

GetString returns the value at path as text, like gjson's Result.String.

func (*Doc) Has

func (d *Doc) Has(path string) bool

Has reports whether path exists.

func (*Doc) Set

func (d *Doc) Set(path string, v any) error

Set stores v at path, creating the objects on the way.

func (*Doc) String

func (d *Doc) String() string

String returns the document as JSON.

Jump to

Keyboard shortcuts

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