dynamic

package
v0.0.0-...-4ebe608 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package dynamic converts a json.Document to dynamic JSON and vice versa.

Dynamic [SON] holds the dynamic go data structure created when unmarshaling JSON into an untyped `interface{}` value.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToDocument

func ToDocument(value JSON, opts ...json.Option) (json.Document, error)

ToDocument builds a json.Document from a dynamic JSON data structure,

i.e. akin to what you get when the standard library unmarshals into a "any" type. TODO Options: specify Store

Types

type JSON

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

JSON holds the dynamic go data structure created when unmarshaling JSON into an untyped `interface{}` value.

The inner structure is built from a JSON string using map[string]any for objects, []any for arrays, string for strings and float64 for numbers.

func Make

func Make(opts ...Option) JSON

Make a new JSON object.

func ToJSON

func ToJSON(d json.Document, opts ...Option) JSON

ToJSON converts a json.Document into a dynamic JSON data structure.

func (JSON) AppendText

func (d JSON) AppendText(b []byte) ([]byte, error)

func (*JSON) Decode

func (d *JSON) Decode(r io.Reader) error

func (JSON) Encode

func (d JSON) Encode(w io.Writer) error

func (JSON) Interface

func (d JSON) Interface() any

Interface returns the inner untyped go structure (type "any").

func (JSON) MarshalJSON

func (d JSON) MarshalJSON() ([]byte, error)

func (*JSON) Reset

func (d *JSON) Reset()

func (*JSON) UnmarshalJSON

func (d *JSON) UnmarshalJSON(data []byte) error

type Option

type Option func(*options)

func WithLexer

func WithLexer(l lexers.Lexer) Option

func WithWriter

func WithWriter(w writers.JSONWriter) Option

Jump to

Keyboard shortcuts

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