jsonnode

package
v0.41.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 4 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jsonnode builds the yaml.Node tree for a JSON document directly, without running yaml's scanner.

yaml parses JSON as a flow collection, and its scanner treats the opening '{' as a potential simple key, so it buffers every token of the document until the closing '}'. For a large JSON specification that is hundreds of megabytes of token queue. JSON's grammar is small enough to parse directly into the exact tree yaml would produce: the same kinds, tags, styles, values, lines and columns.

Parse only accepts input whose yaml parse it reproduces exactly. Anything else (invalid JSON, or valid JSON that yaml reads differently, such as a key separated from its colon by a line break) is declined, and the caller parses it with yaml instead, getting yaml's result or yaml's error.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parse

func Parse(data []byte) (*yaml.Node, bool)

Parse returns the yaml document node yaml.Unmarshal produces for the JSON document in data, and true. It returns false when data is not a JSON object whose yaml parse it reproduces exactly.

func Unmarshal

func Unmarshal(data []byte, out *yaml.Node) error

Unmarshal decodes data into out, producing exactly what yaml.Unmarshal produces: a JSON object is built by Parse, and anything Parse declines is decoded by yaml.Unmarshal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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