json

package
v0.8.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 12 Imported by: 58

Documentation

Overview

Package json converts JSON to and from CUE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode deprecated added in v0.0.12

func Decode(r *cue.Runtime, path string, data []byte) (*cue.Instance, error)

Decode parses JSON-encoded data to a CUE value, using path for position information.

Deprecated: use Extract and build using cue.Context.BuildExpr.

func Extract added in v0.0.12

func Extract(path string, data []byte) (ast.Expr, error)

Extract parses JSON-encoded data to a CUE expression, using path for position information.

func Valid added in v0.0.12

func Valid(b []byte) bool

Valid reports whether data is a valid JSON encoding.

func Validate

func Validate(b []byte, v cue.Value) error

Validate validates JSON and confirms it matches the constraints specified by v.

Types

type Decoder added in v0.0.12

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

A Decoder converts JSON values to CUE.

func NewDecoder added in v0.0.12

func NewDecoder(r *cue.Runtime, path string, src io.Reader) *Decoder

NewDecoder configures a JSON decoder. The path is used to associate position information with each node. The runtime may be nil if the decoder is only used to extract to CUE ast objects.

The runtime may be nil if Decode isn't used.

func (*Decoder) Decode deprecated added in v0.0.12

func (d *Decoder) Decode() (*cue.Instance, error)

Decode converts the current JSON value to a CUE instance. It returns io.EOF if the input has been exhausted.

Deprecated: use Extract and build with cue.Context.BuildExpr.

func (*Decoder) Extract added in v0.0.12

func (d *Decoder) Extract() (ast.Expr, error)

Extract converts the current JSON value to a CUE ast. It returns io.EOF if the input has been exhausted.

Jump to

Keyboard shortcuts

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