typedjson

package
v3.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2022 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Overview

Package typedjson allows encoding and decoding shell syntax trees as JSON. The decoding process needs to know what syntax node types to decode into, so the "typed JSON" requires "Type" keys in some syntax tree node objects:

  • The root node
  • Any node represented as an interface field in the parent Go type

The types of all other nodes can be inferred from context alone.

For the sake of efficiency and simplicity, the "Type" key described above must be first in each JSON object.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(r io.Reader) (syntax.Node, error)

Decode is a shortcut for DecodeOptions.Decode, with the default options.

func Encode

func Encode(w io.Writer, node syntax.Node) error

Encode is a shortcut for EncodeOptions.Encode, with the default options.

Types

type DecodeOptions

type DecodeOptions struct {
}

DecodeOptions allows configuring how syntax nodes are encoded.

func (DecodeOptions) Decode

func (opts DecodeOptions) Decode(r io.Reader) (syntax.Node, error)

Decode writes node to w in its typed JSON form, as described in the package documentation.

type EncodeOptions

type EncodeOptions struct {
	Indent string // e.g. "\t"

}

EncodeOptions allows configuring how syntax nodes are encoded.

func (EncodeOptions) Encode

func (opts EncodeOptions) Encode(w io.Writer, node syntax.Node) error

Encode writes node to w in its typed JSON form, as described in the package documentation.

Jump to

Keyboard shortcuts

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