Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

std/yaml/mod.ts

The Deno Standard Library
Latest
import * as mod from "https://deno.land/std@0.224.0/yaml/mod.ts";

parse and stringify for handling YAML encoded data.

Ported from js-yaml v3.13.1.

If your YAML contains multiple documents in it, you can use parseAll for handling it.

To handle regexp, and undefined types, use EXTENDED_SCHEMA. You can also use custom types by extending schemas.

:warning: Limitations

  • binary type is currently not stable.

For further examples see https://github.com/nodeca/js-yaml/tree/master/examples.

Examples

Example 1

import {
  parse,
  stringify,
} from "https://deno.land/std@0.224.0/yaml/mod.ts";

const data = parse(`
foo: bar
baz:
  - qux
  - quux
`);
console.log(data);
// => { foo: "bar", baz: [ "qux", "quux" ] }

const yaml = stringify({ foo: "bar", baz: ["qux", "quux"] });
console.log(yaml);
// =>
// foo: bar
// baz:
//   - qux
//   - quux

Variables

Standard YAML's core schema.

Default YAML schema. It is not described in the YAML specification.

Extends JS-YAML default schema with additional JavaScript types It is not described in the YAML specification. Functions are no longer supported for security reasons.

Standard YAML's failsafe schema.

v
JSON_SCHEMA
deprecated

Standard YAML's JSON schema.

Functions

Parses content as single YAML document.

Same as parse(), but understands multi-document sources. Applies iterator to each document if specified, or returns array of documents.

Serializes data as a YAML document.