YAML - Maple Help

YAML (.yml, .yaml) File Format

YAML file format

Description

 • YAML (YAML Ain't Markup Language) is a lightweight text-based data standard for describing structured data.
 • As a human-readable format, it offers an alternative to explicitly tagged structured data such as XML. The JSON format is a subset of YAML 1.2.
 • The YAML package provides tools for parsing and generating YAML expressions.
 • The general-purpose commands Import and Export also support this format.

Examples

Parse a YAML string as an expression.

 > $\mathrm{YAML}:-\mathrm{ParseString}\left("\left[1, 2, 3.265, 6.01, 7.373\right]"\right)$
 $\left[{1}{,}{2}{,}{3.265}{,}{6.01}{,}{7.373}\right]$ (1)

Import data from a file in YAML format.

 > $\mathrm{Import}\left("example/address.yaml",\mathrm{base}=\mathrm{datadir}\right)$
 ${table}{}\left(\left[{"founded"}{=}{1988}{,}{"address"}{=}{table}{}\left(\left[{"postalCode"}{=}{"N2V 1K8"}{,}{"province"}{=}{"ON"}{,}{"streetAddress"}{=}{"615 Kumpf Drive"}{,}{"country"}{=}{"Canada"}{,}{"city"}{=}{"Waterloo"}\right]\right){,}{"phoneNumbers"}{=}\left[{table}{}\left(\left[{"type"}{=}{"local"}{,}{"number"}{=}{"+1 \left(519\right) 747-2373"}\right]\right){,}{table}{}\left(\left[{"type"}{=}{"toll-free"}{,}{"number"}{=}{"+1 \left(800\right) 267-6583"}\right]\right){,}{table}{}\left(\left[{"type"}{=}{"fax"}{,}{"number"}{=}{"+1 \left(519\right) 747-5284"}\right]\right)\right]{,}{"companyName"}{=}{"Maplesoft"}\right]\right)$ (2)

Export data to a YAML file in the home directory of the current user.

 > $\mathrm{Mouse}≔\mathrm{table}\left(\left["Genus"="Mus","Species"="musculus"\right]\right)$
 ${\mathrm{Mouse}}{≔}{table}{}\left(\left[{"Genus"}{=}{"Mus"}{,}{"Species"}{=}{"musculus"}\right]\right)$ (3)
 > $\mathrm{Mouse}\left["Family"\right]≔"Muridae"$
 ${{\mathrm{Mouse}}}_{{"Family"}}{≔}{"Muridae"}$ (4)
 > $\mathrm{Mouse}\left["Order"\right]≔"Rodentia"$
 ${{\mathrm{Mouse}}}_{{"Order"}}{≔}{"Rodentia"}$ (5)
 > $\mathrm{Mouse}\left["Class"\right]≔"Mammalia"$
 ${{\mathrm{Mouse}}}_{{"Class"}}{≔}{"Mammalia"}$ (6)
 > $\mathrm{Export}\left("mouse.yaml",\mathrm{Mouse},\mathrm{base}=\mathrm{homedir}\right)$
 ${80}$ (7)

References

 YAML 1.2 Language Specification, http://www.yaml.org/spec/1.2/spec.html, yaml.org.