YAML - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

# Online Help

###### All Products    Maple    MapleSim

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[{"phoneNumbers"}{=}\left[{table}{}\left(\left[{"number"}{=}{"+1 \left(519\right) 747-2373"}{,}{"type"}{=}{"local"}\right]\right){,}{table}{}\left(\left[{"number"}{=}{"+1 \left(800\right) 267-6583"}{,}{"type"}{=}{"toll-free"}\right]\right){,}{table}{}\left(\left[{"number"}{=}{"+1 \left(519\right) 747-5284"}{,}{"type"}{=}{"fax"}\right]\right)\right]{,}{"founded"}{=}{1988}{,}{"companyName"}{=}{"Maplesoft"}{,}{"address"}{=}{table}{}\left(\left[{"city"}{=}{"Waterloo"}{,}{"postalCode"}{=}{"N2V 1K8"}{,}{"province"}{=}{"ON"}{,}{"country"}{=}{"Canada"}{,}{"streetAddress"}{=}{"615 Kumpf Drive"}\right]\right)\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[{"Species"}{=}{"musculus"}{,}{"Genus"}{=}{"Mus"}\right]\right)$ (3)
 > ${\mathrm{Mouse}}_{"Family"}≔"Muridae"$
 ${{\mathrm{Mouse}}}_{{"Family"}}{≔}{"Muridae"}$ (4)
 > ${\mathrm{Mouse}}_{"Order"}≔"Rodentia"$
 ${{\mathrm{Mouse}}}_{{"Order"}}{≔}{"Rodentia"}$ (5)
 > ${\mathrm{Mouse}}_{"Class"}≔"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.

 See Also