jsonx

package
v0.0.0-...-758a717 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DropWrapAll

func DropWrapAll(n *Node)

func ParseNumber

func ParseNumber(s string) (interface{}, bool)

ParseNumber parses a number from a string as int64 or *big.Int.

func Wrap

func Wrap(n *Node, termWidth int)

Types

type JsonParser

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

func NewJsonParser

func NewJsonParser(rd io.Reader, strict bool) *JsonParser

func (*JsonParser) Parse

func (p *JsonParser) Parse() (node *Node, err error)

func (*JsonParser) Recover

func (p *JsonParser) Recover() *Node

type Kind

type Kind byte
const (
	Err Kind = iota
	Null
	Bool
	Number
	String
	Object
	Array
	NaN
	Infinity
	Undefined
)

type LineParser

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

func NewLineParser

func NewLineParser(in io.Reader) *LineParser

func (*LineParser) Parse

func (p *LineParser) Parse() (*Node, error)

func (*LineParser) Recover

func (p *LineParser) Recover() *Node

type Node

type Node struct {
	Prev, Next, End *Node
	Parent          *Node
	Collapsed       *Node
	Depth           uint8
	Kind            Kind
	Key             string
	Value           string
	Size            int
	Chunk           string
	ChunkEnd        *Node
	Comma           bool
	Index           int
	LineNumber      int
}

func DeleteNode

func DeleteNode(at *Node) (*Node, bool)

DeleteNode removes the node at from the linked structure and returns a node to select next. It returns (nextToSelect, true) if deletion happened, or (nil, false) if nothing was deleted. Rules: - Do nothing if at is nil, points to root (no parent), or is a bracket/closing node (Index == -1). - If at is a wrap placeholder (Chunk set, Value empty), operate on its parent value. - Maintain Prev/Next links skipping the deleted range [at..endOf]. - Clear trailing comma on the previous sibling when deleting the last child before parent's End. - Decrement parent.Size and reindex subsequent array siblings. - Choose selection: prefer next; if next is nil or parent.End, prefer prev; else parent.

func Parse

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

func (*Node) Adjacent

func (n *Node) Adjacent(child *Node)

Adjacent adds a node as a sibling to the current node ({}{}{} or [][][]).

func (*Node) Append

func (n *Node) Append(child *Node)

Append ands a node as a child to the current node (body of {...} or [...]).

func (*Node) Bottom

func (n *Node) Bottom() *Node

func (*Node) Children

func (n *Node) Children() ([]string, []*Node)

func (*Node) Collapse

func (n *Node) Collapse() *Node

func (*Node) CollapseRecursively

func (n *Node) CollapseRecursively()

func (*Node) Expand

func (n *Node) Expand()

func (*Node) ExpandRecursively

func (n *Node) ExpandRecursively(level, maxLevel int)

func (*Node) FindByPath

func (n *Node) FindByPath(path []any) *Node

func (*Node) FindNextNonErr

func (n *Node) FindNextNonErr() *Node

func (*Node) ForEach

func (n *Node) ForEach(cb func(*Node))

func (*Node) HasChildren

func (n *Node) HasChildren() bool

func (*Node) IsCollapsed

func (n *Node) IsCollapsed() bool

func (*Node) IsWrap

func (n *Node) IsWrap() bool

func (*Node) Paths

func (n *Node) Paths(paths *[]string, nodes *[]*Node)

func (*Node) Root

func (n *Node) Root() *Node

func (*Node) String

func (n *Node) String() string

func (*Node) ToValue

func (n *Node) ToValue(vm *goja.Runtime) goja.Value

Jump to

Keyboard shortcuts

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