1YAML::XS(3)           User Contributed Perl Documentation          YAML::XS(3)
2
3
4

NAME

6       YAML::XS - Perl YAML Serialization using XS and libyaml
7

SYNOPSIS

9           use YAML::XS;
10
11           my $yaml = Dump [ 1..4 ];
12           my $array = Load $yaml;
13

DESCRIPTION

15       Kirill Siminov's "libyaml" is arguably the best YAML implementation.
16       The C library is written precisely to the YAML 1.1 specification. It
17       was originally bound to Python and was later bound to Ruby.
18
19       This module is a Perl XS binding to libyaml which offers Perl the best
20       YAML support to date.
21
22       This module exports the functions "Dump", "Load", "DumpFile" and
23       "LoadFile". These functions are intended to work exactly like
24       "YAML.pm"'s corresponding functions. Only "Load" and "Dump" are
25       exported by default.
26

CONFIGURATION

28       $YAML::XS::LoadBlessed (since v0.69)
29           Default: true. The default might be changed to false in the future.
30
31           When set to false, it will not bless data into objects, which can
32           be a security problem, when loading YAML from an untrusted source.
33           It will silently ignore the tag and just load the data unblessed.
34
35           In PyYAML, this is called SafeLoad.
36
37           If set to true, it will load the following YAML as objects:
38
39               ---
40               local: !Foo::Bar [a]
41               perl: !!perl/hash:Foo::Bar { a: 1 }
42               regex: !!perl/regexp:Foo::Bar pattern
43
44       $YAML::XS::UseCode
45       $YAML::XS::DumpCode
46       $YAML::XS::LoadCode
47           If enabled supports deparsing and evaling of code blocks.
48
49       $YAML::XS::QuoteNumericStrings
50           When true (the default) strings that look like numbers but have not
51           been numified will be quoted when dumping.
52
53           This ensures leading that things like leading zeros and other
54           formatting are preserved.
55
56       $YAML::XS::Boolean (since v0.67)
57           Default is undef.
58
59           When set to "JSON::PP" or "boolean", the plain (unquoted) strings
60           "true" and "false" will be loaded as "JSON::PP::Boolean" or
61           "boolean.pm" objects. Those objects will be dumped again as plain
62           "true" or "false".
63
64           It will try to load JSON::PP or boolean and die if it can't be
65           loaded.
66
67           With that it's possible to add new "real" booleans to a data
68           structure:
69
70                 local $YAML::XS::Boolean = "JSON::PP"; # or "boolean"
71                 my $data = Load("booltrue: true");
72                 $data->{boolfalse} = JSON::PP::false;
73                 my $yaml = Dump($data);
74                 # boolfalse: false
75                 # booltrue: true
76
77           It also lets booleans survive when loading YAML via YAML::XS and
78           encode it in JSON via one of the various JSON encoders, which
79           mostly support JSON::PP booleans.
80
81           Please note that JSON::PP::Boolean and boolean.pm behave a bit
82           differently.  Ideally you should only use them in boolean context.
83
84           If not set, booleans are loaded as special perl variables
85           "PL_sv_yes" and "PL_sv_no", which have the disadvantage that they
86           are readonly, and you can't add those to an existing data structure
87           with pure perl.
88
89           If you simply need to load "perl booleans" that are true or false
90           in boolean context, you will be fine with the default setting.
91

USING YAML::XS WITH UNICODE

93       Handling unicode properly in Perl can be a pain. YAML::XS only deals
94       with streams of utf8 octets. Just remember this:
95
96           $perl = Load($utf8_octets);
97           $utf8_octets = Dump($perl);
98
99       There are many, many places where things can go wrong with unicode. If
100       you are having problems, use Devel::Peek on all the possible data
101       points.
102

SEE ALSO

104       ·   YAML.pm
105
106       ·   YAML::Syck
107
108       ·   YAML::Tiny
109

AUTHOR

111       Ingy döt Net <ingy@cpan.org>
112
114       Copyright 2007-2018. Ingy döt Net.
115
116       This program is free software; you can redistribute it and/or modify it
117       under the same terms as Perl itself.
118
119       See <http://www.perl.com/perl/misc/Artistic.html>
120
121
122
123perl v5.28.0                      2018-09-01                       YAML::XS(3)
Impressum