yaml

package module
v1.0.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

README

YAML Module

github.com/MontFerret/contrib/modules/yaml registers YAML helpers under the YAML namespace for Ferret hosts.

The module exposes these functions:

  • YAML::DECODE
  • YAML::DECODE_ALL
  • YAML::ENCODE

Install

go get github.com/MontFerret/contrib/modules/yaml

Register The Module

package main

import (
	"github.com/MontFerret/ferret/v2"

	yamlmodule "github.com/MontFerret/contrib/modules/yaml"
)

func main() {
	yamlMod, err := yamlmodule.New()
	if err != nil {
		panic(err)
	}

	engine, err := ferret.New(
		ferret.WithModules(yamlMod),
	)
	if err != nil {
		panic(err)
	}

	_ = engine
}

Function Reference

Function Signature Returns Notes
YAML::DECODE YAML::DECODE(data) Any Decodes exactly one YAML document. Rejects streams with multiple documents.
YAML::DECODE_ALL YAML::DECODE_ALL(data) Any[] Decodes all YAML documents from a YAML stream in order.
YAML::ENCODE YAML::ENCODE(value) String Encodes a supported Ferret runtime value into YAML text.

Type Mapping

Decoded YAML values map to Ferret runtime values as follows:

YAML Ferret
mapping Object
sequence Array
string String
integer Int
float Float
boolean Boolean
null None

Examples

Decode A Single Document
RETURN YAML::DECODE("
name: Alice
age: 30
active: true
")
Decode A Multi-Document Stream
RETURN YAML::DECODE_ALL("
---
name: Alice
---
- 1
- 2
")
Encode A Value
RETURN YAML::ENCODE({
  name: "Alice",
  age: 30,
  tags: ["yaml", "ferret"]
})

Behavior Notes

  • YAML::DECODE and YAML::DECODE_ALL accept both string and binary YAML input.
  • Empty input is rejected by both decode functions.
  • YAML::DECODE rejects YAML streams that contain more than one document.
  • Anchors, aliases, and merge keys are accepted only when they resolve to ordinary data values.
  • YAML::ENCODE supports only plain data values; unsupported runtime types such as binary, datetime, and iterator-like values return an error.
  • Output formatting is implementation-defined in v1.

Documentation

Overview

Package yaml registers the YAML module for Ferret hosts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() module.Module

New returns the YAML module, which registers the YAML namespace functions on a Ferret host during bootstrap.

Types

This section is empty.

Directories

Path Synopsis
Package core implements the YAML decoding and encoding primitives shared by the YAML module wrappers.
Package core implements the YAML decoding and encoding primitives shared by the YAML module wrappers.
Package lib exposes the Ferret-facing YAML:: functions.
Package lib exposes the Ferret-facing YAML:: functions.

Jump to

Keyboard shortcuts

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