json

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromJSON

func FromJSON(r io.Reader, vrw types.ValueReadWriter, opts FromOptions) (types.Value, error)

func NomsValueFromDecodedJSON

func NomsValueFromDecodedJSON(vrw types.ValueReadWriter, o interface{}, useStruct bool) types.Value

NomsValueFromDecodedJSON takes a generic Go interface{} and recursively tries to resolve the types within so that it can build up and return a Noms Value with the same structure.

Currently, the only types supported are the Go versions of legal JSON types: Primitives:

  • float64
  • bool
  • string
  • nil

Composites:

  • []interface{}
  • map[string]interface{}

func ToJSON

func ToJSON(v types.Value, w io.Writer, opts ToOptions) error

ToJSON encodes a Noms value as JSON.

Types

type FromOptions

type FromOptions struct {
	// If true, JSON objects are decoded into Noms Structs. Otherwise, they are decoded into Maps.
	Structs bool
}

FromOptions controls how FromJSON works.

type ToOptions

type ToOptions struct {
	// Enable support for encoding Noms Lists. Lists are encoded as JSON arrays.
	Lists bool
	// Enable support for encoding Noms Maps. Maps are encoded as JSON objects.
	Maps bool
	// Enable support for encoding Noms Sets. Sets are encoded as JSON arrays.
	Sets bool
	// Enable support for encoding Noms Structs. Structs are encoded as JSON objects.
	Structs bool
	// String to use for indent when pretty-printing
	Indent string
}

ToOptions controls how ToJSON works.

Jump to

Keyboard shortcuts

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