codec

package
v0.1.16 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromJSON

func FromJSON(str string) map[string]interface{}

FromJSON converts a JSON document into a map[string]interface{}.

This is not a general-purpose JSON parser, and will not parse all valid JSON documents. Additionally, because its intended use is within templates it tolerates errors. It will insert the returned error message string into m["Error"] in the returned map.

func FromJSONArray

func FromJSONArray(str string) []interface{}

FromJSONArray converts a JSON array into a []interface{}.

This is not a general-purpose JSON parser, and will not parse all valid JSON documents. Additionally, because its intended use is within templates it tolerates errors. It will insert the returned error message string as the first and only item in the returned array.

func FromYAML

func FromYAML(str string) map[string]interface{}

FromYAML converts a YAML document into a map[string]interface{}.

This is not a general-purpose YAML parser, and will not parse all valid YAML documents. Additionally, because its intended use is within templates it tolerates errors. It will insert the returned error message string into m["Error"] in the returned map.

func FromYAMLArray

func FromYAMLArray(str string) []interface{}

FromYAMLArray converts a YAML array into a []interface{}.

This is not a general-purpose YAML parser, and will not parse all valid YAML documents. Additionally, because its intended use is within templates it tolerates errors. It will insert the returned error message string as the first and only item in the returned array.

func ToJSON

func ToJSON(v interface{}) string

ToJSON takes an interface, marshals it to json, and returns a string. It will always return a string, even on marshal error (empty string).

This is designed to be called from a template.

func ToTOML

func ToTOML(v interface{}) string

ToTOML takes an interface, marshals it to toml, and returns a string. It will always return a string, even on marshal error (empty string).

This is designed to be called from a template.

func ToYAML

func ToYAML(v interface{}) string

ToYAML takes an interface, marshals it to yaml, and returns a string. It will always return a string, even on marshal error (empty string).

This is designed to be called from a template.

Types

This section is empty.

Jump to

Keyboard shortcuts

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