1yaml(n)                         YAML processing                        yaml(n)
2
3
4
5______________________________________________________________________________
6

NAME

8       yaml - YAML Format Encoder/Decoder
9

SYNOPSIS

11       package require Tcl  8.4
12
13       package require yaml  ?0.4.1?
14
15       ::yaml::yaml2dict ?options? txt
16
17       ::yaml::yaml2huddle ?options? txt
18
19       ::yaml::setOption ?options?
20
21       ::yaml::dict2yaml dict ?indent? ?wordwrap?
22
23       ::yaml::list2yaml list ?indent? ?wordwrap?
24
25       ::yaml::huddle2yaml huddle ?indent? ?wordwrap?
26
27______________________________________________________________________________
28

DESCRIPTION

30       The  yaml  package  provides  a simple Tcl-only library for parsing the
31       YAML  http://www.yaml.org/  data  exchange  format  as   specified   in
32       http://www.yaml.org/spec/1.1/.
33
34       The  yaml  package returns data as a Tcl dict.  Either the dict package
35       or Tcl 8.5 is required for use.
36

COMMANDS

38       ::yaml::yaml2dict ?options? txt
39
40       ::yaml::yaml2huddle ?options? txt
41              Parse yaml formatted text txt into a Tcl dict/huddle and  return
42              the value.
43
44              -file  txt is a filename of YAML-stream.
45
46              -stream
47                     txt is just a YAML-stream.
48
49              -types list
50                     The  list  is a type list for the yaml-scalar types.(e.g.
51                     !!str !!timestamp !!integer !!true ...)
52
53                      -types {timestamp integer null true false}
54
55                     In this case, if a string matched "timestamp",  converted
56                     to       the       TCL      internal      timestamp.(e.g.
57                     "2001-12-15T02:59:43.1Z" => 1008385183)
58
59              -m:true param
60                     The param is two elements of list for the value of  true,
61                     and considered strings.
62
63                      -m:true {1 {true on + yes y}}
64
65                     In  this case, the string "yes" found in YAML Stream, au‐
66                     tomatically converted 1.
67
68              -m:false param
69                     The param is two elements of list for the value of false,
70                     and considered strings.
71
72                      -m:false {0 {false off - no n}}
73
74              -m:null param
75                     The  param is two elements of list for the value of null,
76                     and considered strings.
77
78                      -m:null {"" {null nil "" ~}}
79
80              -validate
81                     Experiment,old: Output stream contains  YAML's-tag,  each
82                     node.
83
84                     % puts [::yaml::load -validate {[aaa, bbb]}]
85                     =>
86                     !!seq {{!!str aaa} {!!str bbb}}
87
88
89       ::yaml::setOption ?options?
90              Change  implicit  options  for the library.  Now, the params are
91              the same as ::yaml::yaml2dict.  Arguments of::yaml::yaml2dict is
92              more priority than this setting.
93
94       ::yaml::dict2yaml dict ?indent? ?wordwrap?
95
96       ::yaml::list2yaml list ?indent? ?wordwrap?
97
98       ::yaml::huddle2yaml huddle ?indent? ?wordwrap?
99              Convert a dict/list/huddle object into YAML stream.
100
101              indent spaces  indent  of each block node.  currently default is
102                     2.
103
104              wordwrap
105                     word wrap for YAML stream.  currently default is 40.
106

EXAMPLES

108       An example of a yaml stream converted to Tcl.  A  yaml  stream  is  re‐
109       turned as a single item with multiple elements.
110
111              {
112              --- !<tag:clarkevans.com,2002:invoice>
113              invoice: 34843
114              date   : 2001-01-23
115              bill-to: &id001
116                  given  : Chris
117                  family : Dumars
118                  address:
119                      lines: |
120                          458 Walkman Dr.
121                          Suite #292
122                      city    : Royal Oak
123                      state   : MI
124                      postal  : 48046
125              ship-to: *id001
126              product:
127                  - sku         : BL394D
128                    quantity    : 4
129                    description : Basketball
130                    price       : 450.00
131                  - sku         : BL4438H
132                    quantity    : 1
133                    description : Super Hoop
134                    price       : 2392.00
135              tax  : 251.42
136              total: 4443.52
137              comments:
138                  Late afternoon is best.
139                  Backup contact is Nancy
140                  Billsmer @ 338-4338.
141              }
142              =>
143              invoice 34843 date 2001-01-23 bill-to {given Chris family Dumars address {lines {458 Walkman Dr.
144              Suite #292
145              } city {Royal Oak} state MI postal 48046}} ship-to {given Chris family Dumars address {lines {458 Walkman Dr.
146              Suite #292
147              } 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.}
148
149       An  example  of  a  yaml object converted to Tcl.  A yaml object is re‐
150       turned as a multi-element list (a dict).
151
152              {
153              ---
154              - [name        , hr, avg  ]
155              - [Mark McGwire, 65, 0.278]
156              - [Sammy Sosa  , 63, 0.288]
157              -
158                Mark McGwire: {hr: 65, avg: 0.278}
159                Sammy Sosa: { hr: 63, avg: 0.288}
160              }
161              =>
162              {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}}
163
164

LIMITATIONS

166       tag parser not implemented. currentry, tags are merely ignored.
167
168       Only Anchor => Aliases ordering. back alias-referring is not supported.
169
170       Too many braces, or too few braces.
171
172       Not enough character set of line feeds. Please use only  "\n"  as  line
173       breaks.
174

BUGS, IDEAS, FEEDBACK

176       This  document,  and the package it describes, will undoubtedly contain
177       bugs and other problems.  Please report such in the  category  yaml  of
178       the  Tcllib  Trackers  [http://core.tcl.tk/tcllib/reportlist].   Please
179       also report any ideas for enhancements you may have for either  package
180       and/or documentation.
181
182       When proposing code changes, please provide unified diffs, i.e the out‐
183       put of diff -u.
184
185       Note further that  attachments  are  strongly  preferred  over  inlined
186       patches.  Attachments  can  be  made  by  going to the Edit form of the
187       ticket immediately after its creation, and  then  using  the  left-most
188       button in the secondary navigation bar.
189

SEE ALSO

191       base64, huddle, json
192

KEYWORDS

194       data exchange, huddle, parsing, text processing, yaml
195
197       Copyright (c) 2008 KATO Kanryu <kanryu6@users.sourceforge.net>
198
199
200
201
202tcllib                               0.4.1                             yaml(n)
Impressum