yaml - YAML Format Encoder/Decoder
The yaml package provides a simple Tcl-only library for parsing the YAML http://www.yaml.org/ data exchange format as specified in http://www.yaml.org/spec/1.1/.
The yaml package returns data as a Tcl dict. Either the dict package or Tcl 8.5 is required for use.
Parse yaml formatted text txt into a Tcl dict/huddle and return the value.
Change implicit options for the library. Now, the params are the same as ::yaml::yaml2dict. Arguments of::yaml::yaml2dict is more priority than this setting.
Convert a dict/list/huddle object into YAML stream.
spaces indent of each block node. currently default is 2.
word wrap for YAML stream. currently default is 40.
An example of a yaml stream converted to Tcl. A yaml stream is returned as a single item with multiple elements.
{ --- !<tag:clarkevans.com,2002:invoice> invoice: 34843 date : 2001-01-23 bill-to: &id001 given : Chris family : Dumars address: lines: | 458 Walkman Dr. Suite #292 city : Royal Oak state : MI postal : 48046 ship-to: *id001 product: - sku : BL394D quantity : 4 description : Basketball price : 450.00 - sku : BL4438H quantity : 1 description : Super Hoop price : 2392.00 tax : 251.42 total: 4443.52 comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. } => invoice 34843 date 2001-01-23 bill-to {given Chris family Dumars address {lines {458 Walkman Dr. Suite #292 } city {Royal Oak} state MI postal 48046}} ship-to {given Chris family Dumars address {lines {458 Walkman Dr. Suite #292 } city {Royal Oak} state MI postal 48046}} product {{sku BL394D quantity 4 description Basketball price 450.00} {sku BL4438H quantity 1 description {Super Hoop} price 2392.00}} tax 251.42 total 4443.52 comments {Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338.}
An example of a yaml object converted to Tcl. A yaml object is returned as a multi-element list (a dict).
{ --- - [name , hr, avg ] - [Mark McGwire, 65, 0.278] - [Sammy Sosa , 63, 0.288] - Mark McGwire: {hr: 65, avg: 0.278} Sammy Sosa: { hr: 63, avg: 0.288} } => {name hr avg} {{Mark McGwire} 65 0.278} {{Sammy Sosa} 63 0.288} {{Mark McGwire} {hr 65 avg 0.278} {Sammy Sosa} {hr 63 avg 0.288}}
tag parser not implemented. currentry, tags are merely ignored.
Only Anchor => Aliases ordering. back alias-referring is not supported.
Too many braces, or too few braces.
Not enough character set of line feeds. Please use only "\n" as line breaks.
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category yaml of the Tcllib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
When proposing code changes, please provide unified diffs, i.e the output of diff -u.
Note further that attachments are strongly preferred over inlined patches. Attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar.
Copyright © 2008 KATO Kanryu <kanryu6@users.sourceforge.net>