astjson

package
v2.0.0-rc.62 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const InvalidRef = -1

Variables

View Source
var (
	Pool = &pool{
		p: sync.Pool{
			New: func() interface{} {
				return &JSON{
					Nodes: make([]Node, 0, 4096),
				}
			},
		},
	}
	ErrParseJSONObject = errors.New("failed to parse json object")
	ErrParseJSONArray  = errors.New("failed to parse json array")
	ErrParseJSONValue  = errors.New("failed to parse json value")
)

Functions

This section is empty.

Types

type JSON

type JSON struct {
	Nodes    []Node
	RootNode int
	// contains filtered or unexported fields
}

func (*JSON) AppendAnyJSONBytes

func (j *JSON) AppendAnyJSONBytes(input []byte) (ref int, err error)

func (*JSON) AppendArray

func (j *JSON) AppendArray(input []byte) (ref int, err error)

func (*JSON) AppendArrayValue

func (j *JSON) AppendArrayValue(arrayNodeRef, newItemRef int)

func (*JSON) AppendErrorWithMessage

func (j *JSON) AppendErrorWithMessage(message string, errorPath []PathElement) int

func (*JSON) AppendInt

func (j *JSON) AppendInt(value int) int

func (*JSON) AppendJSON

func (j *JSON) AppendJSON(another *JSON) (nodeRef, storageOffset, nodeOffset int)

func (*JSON) AppendNonNullableFieldIsNullErr

func (j *JSON) AppendNonNullableFieldIsNullErr(fieldPath string, errorPath []PathElement) int

func (*JSON) AppendNull

func (j *JSON) AppendNull() int

func (*JSON) AppendObject

func (j *JSON) AppendObject(input []byte) (ref int, err error)

func (*JSON) AppendString

func (j *JSON) AppendString(input string) int

func (*JSON) AppendStringBytes

func (j *JSON) AppendStringBytes(input []byte) int

func (*JSON) DebugPrintNode

func (j *JSON) DebugPrintNode(ref int) string

func (*JSON) Get

func (j *JSON) Get(nodeRef int, path []string) int

func (*JSON) GetObjectField

func (j *JSON) GetObjectField(nodeRef int, path string) int

func (*JSON) GetObjectFieldBytes

func (j *JSON) GetObjectFieldBytes(nodeRef int, path []byte) int

func (*JSON) ImportPrimitiveNode

func (j *JSON) ImportPrimitiveNode(from *JSON, ref int) (int, error)

func (*JSON) InitResolvable

func (j *JSON) InitResolvable(initialData []byte) (dataRoot, errorsRoot int, err error)

func (*JSON) MergeArrays

func (j *JSON) MergeArrays(left, right int)

func (*JSON) MergeNodes

func (j *JSON) MergeNodes(left, right int) int

func (*JSON) MergeNodesWithPath

func (j *JSON) MergeNodesWithPath(left, right int, path []string) int

func (*JSON) MergeObjects

func (j *JSON) MergeObjects(nodeRefs []int) int

func (*JSON) NodeIsDefined

func (j *JSON) NodeIsDefined(ref int) bool

func (*JSON) NodeIsPrimitive

func (j *JSON) NodeIsPrimitive(ref int) bool

func (*JSON) ObjectFieldKey

func (j *JSON) ObjectFieldKey(objectFieldRef int) []byte

func (*JSON) ObjectFieldValue

func (j *JSON) ObjectFieldValue(objectFieldRef int) int

func (*JSON) ParseArray

func (j *JSON) ParseArray(input []byte) (err error)

func (*JSON) ParseObject

func (j *JSON) ParseObject(input []byte) (err error)

func (*JSON) PrintNode

func (j *JSON) PrintNode(node Node, out io.Writer) error

func (*JSON) PrintObjectFlat

func (j *JSON) PrintObjectFlat(ref int, out io.Writer) (err error)

PrintObjectFlat prints the flat object without nested fields (array, object)

func (*JSON) PrintRoot

func (j *JSON) PrintRoot(out io.Writer) error

func (*JSON) Reset

func (j *JSON) Reset()

func (*JSON) SetObjectField

func (j *JSON) SetObjectField(nodeRef, setFieldNodeRef int, key string) bool

func (*JSON) SetObjectFieldKeyBytes

func (j *JSON) SetObjectFieldKeyBytes(nodeRef, setFieldNodeRef int, key []byte) bool

func (*JSON) Size

func (j *JSON) Size() int

type Node

type Node struct {
	Kind             NodeKind
	ObjectFieldValue int

	ObjectFields []int
	ArrayValues  []int
	// contains filtered or unexported fields
}

func (*Node) ValueBytes

func (n *Node) ValueBytes(j *JSON) []byte

type NodeKind

type NodeKind int
const (
	NodeKindSkip NodeKind = iota
	NodeKindObject
	NodeKindObjectField
	NodeKindArray
	NodeKindString
	NodeKindNumber
	NodeKindBoolean
	NodeKindNull
	// NodeKindNullSkipError indicates that the node is null, but no error should be emitted
	// There's no need to emit an error if the field should be non-nullable,
	// because an error was already emitted when the field was fetched
	// or a nested error was emitted, so there's no need to emit another one
	NodeKindNullSkipError
)

type PathElement

type PathElement struct {
	ArrayIndex int
	Name       string
}

Jump to

Keyboard shortcuts

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