jsonutil

package
v0.0.51 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package jsonutil provides JSON utility functions, complementing the more common ones in the encoding/json package.

Index

Constants

View Source
const NilDocument = Document("")

Variables

This section is empty.

Functions

This section is empty.

Types

type Document

type Document string

Document represents a JSON document.

func ReadDocument

func ReadDocument(reader io.Reader) (Document, error)

ReadDocument reads a document from the given reader.

func (Document) Child

func (d Document) Child(path string) Document

Child returns a new Document representing the child element at the specified path.

func (Document) Children

func (d Document) Children(path string) []Document

Children returns an array of child documents that match the given path.

func (Document) Float64

func (d Document) Float64(path string) float64

Float64 returns the float64 value at the specified JSON path.

func (Document) Int

func (d Document) Int(path string) int

Int returns the integer value at the specified JSON path.

func (Document) RootUUIDs added in v0.0.49

func (d Document) RootUUIDs() []uuid.UUID

func (Document) String

func (d Document) String() string

String returns the string representation of the document.

func (Document) Time

func (d Document) Time(path string) time.Time

Time returns the time value at the specified JSON path.

func (Document) UUID

func (d Document) UUID(path string) uuid.UUID

UUID returns the UUID value at the specified JSON path.

func (Document) UUIDs

func (d Document) UUIDs(path string) []uuid.UUID

UUIDs returns an array of UUIDs that match the given path.

type Template

type Template json.RawMessage

Template is a JSON template.

func NewTemplate

func NewTemplate(template json.RawMessage) Template

func (Template) Reader

func (t Template) Reader() io.Reader

Reader returns a reader for the template.

func (Template) Replace

func (t Template) Replace(key string, value json.RawMessage) Template

Replace all occurrences of a key with a value in the template.

func (Template) String

func (t Template) String() string

Jump to

Keyboard shortcuts

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