encoding

package
v1.0.17 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

encoding package handles marshal and unmarshaling documents into various formats, such as json, bson, yaml, etc. Do not directly use the yaml.Unmarshal, etc, use these.

Index

Constants

View Source
const (
	Yaml = "yaml"
	Json = "json"
	Toml = "toml"
)

Variables

This section is empty.

Functions

func Marshal

func Marshal(format string, in interface{}) (data []byte, err error)

Marshal a struct to the specified format. Supported formats are: yaml, json, and toml.

func MarshalFile

func MarshalFile(fs aferox.Aferox, path string, in interface{}) error

MarshalFile encodes the specified struct to a file. Supported file extensions are: yaml, yml, json, and toml.

func MarshalJson

func MarshalJson(in interface{}) ([]byte, error)

MarshalJson converts the input struct to json.

func MarshalToml

func MarshalToml(in interface{}) ([]byte, error)

MarshalToml converts the input to toml.

func MarshalYaml

func MarshalYaml(in interface{}) ([]byte, error)

MarshalYaml converts the input to yaml.

func Unmarshal

func Unmarshal(format string, data []byte, out interface{}) error

Unmarshal from the specified format into a struct. Supported formats are: yaml, json, and toml.

func UnmarshalFile

func UnmarshalFile(fs aferox.Aferox, path string, out interface{}) error

Unmarshal from the specified file into a struct. Supported file extensions are: yaml, yml, json, and toml.

func UnmarshalJson

func UnmarshalJson(data []byte, out interface{}) error

UnmarshalJson converts the input json to a struct.

func UnmarshalToml

func UnmarshalToml(data []byte, out interface{}) error

UnmarshalToml converts the input toml to a struct.

func UnmarshalYaml

func UnmarshalYaml(data []byte, out interface{}) error

UnmarshalYaml converts the input yaml to a struct.

Types

This section is empty.

Jump to

Keyboard shortcuts

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