yamlutils

package module
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2025 License: Apache-2.0 Imports: 7 Imported by: 2

Documentation

Overview

Package yamlutils provides utilities to work with YAML documents.

Index

Constants

View Source
const (
	// ErrYAML is an error raised by YAML utilities
	ErrYAML yamlError = "yaml error"
)

Variables

This section is empty.

Functions

func BytesToYAMLDoc

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

BytesToYAMLDoc converts a byte slice into a YAML document.

This function only supports root documents that are objects.

A YAML document is a pointer to a yaml.Node.

func YAMLToJSON

func YAMLToJSON(value interface{}) (json.RawMessage, error)

YAMLToJSON converts a YAML document into JSON bytes.

Note: a YAML document is the output from a yaml.Marshaler, e.g a pointer to a yaml.Node.

Types

type YAMLMapItem

type YAMLMapItem = jsonutils.JSONMapItem

YAMLMapItem represents the value of a key in a YAML object held by YAMLMapSlice.

It is entirely equivalent to jsonutils.JSONMapItem, with the same limitation that you should not Marshal or Unmarshal directly this type, outside of a YAMLMapSlice.

type YAMLMapSlice

type YAMLMapSlice []YAMLMapItem

YAMLMapSlice represents a YAML object, with the order of keys maintained.

It is similar to jsonutils.JSONMapSlice and also knows how to marshal and unmarshal YAML.

func (YAMLMapSlice) MarshalJSON

func (s YAMLMapSlice) MarshalJSON() ([]byte, error)

MarshalJSON renders this YAML object as JSON bytes.

func (YAMLMapSlice) MarshalYAML

func (s YAMLMapSlice) MarshalYAML() (interface{}, error)

MarshalYAML produces a YAML document as bytes

func (*YAMLMapSlice) UnmarshalJSON

func (s *YAMLMapSlice) UnmarshalJSON(data []byte) error

UnmarshalJSON builds this YAML object from JSON bytes.

Jump to

Keyboard shortcuts

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