yaml

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package yaml provides YAML <-> JSON conversion for OPA, on top of go.yaml.in/yaml/v3.

It replaces sigs.k8s.io/yaml, which is pinned to go.yaml.in/yaml/v2 and therefore resolves YAML 1.1 boolean spellings (on/off/yes/no) in positions where the YAML 1.2 core schema calls for strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONToYAML

func JSONToYAML(bs []byte) ([]byte, error)

JSONToYAML converts JSON to YAML, preserving nothing but the value.

func Marshal

func Marshal(obj any) ([]byte, error)

Marshal serializes obj as YAML. obj is first round-tripped through encoding/json so that `json` struct tags and json.Marshaler implementations are honoured, matching the behaviour callers relied on from sigs.k8s.io/yaml.

func Unmarshal

func Unmarshal(bs []byte, obj any, opts ...JSONOpt) error

Unmarshal decodes a YAML document into obj, using encoding/json semantics (`json` struct tags, json.Unmarshaler) rather than go-yaml's.

func YAMLToJSON

func YAMLToJSON(bs []byte) ([]byte, error)

YAMLToJSON converts a single YAML document to JSON. Input holding more than one document keeps its historical meaning - only the first is converted - but the rest of the stream still has to parse.

Types

type JSONOpt

type JSONOpt func(*json.Decoder) *json.Decoder

JSONOpt configures the encoding/json decoder used by Unmarshal.

Jump to

Keyboard shortcuts

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