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 Simonov'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           Note that support for loading code was added in version 0.75,
50           although $LoadCode was documented already in earlier versions.
51
52       $YAML::XS::QuoteNumericStrings
53           When true (the default) strings that look like numbers but have not
54           been numified will be quoted when dumping.
55
56           This ensures leading that things like leading zeros and other
57           formatting are preserved.
58
59       $YAML::XS::Boolean (since v0.67)
60           Default is undef.
61
62           When set to "JSON::PP" or "boolean", the plain (unquoted) strings
63           "true" and "false" will be loaded as "JSON::PP::Boolean" or
64           "boolean.pm" objects. Those objects will be dumped again as plain
65           "true" or "false".
66
67           It will try to load JSON::PP or boolean and die if it can't be
68           loaded.
69
70           With that it's possible to add new "real" booleans to a data
71           structure:
72
73                 local $YAML::XS::Boolean = "JSON::PP"; # or "boolean"
74                 my $data = Load("booltrue: true");
75                 $data->{boolfalse} = JSON::PP::false;
76                 my $yaml = Dump($data);
77                 # boolfalse: false
78                 # booltrue: true
79
80           It also lets booleans survive when loading YAML via YAML::XS and
81           encode it in JSON via one of the various JSON encoders, which
82           mostly support JSON::PP booleans.
83
84           Please note that JSON::PP::Boolean and boolean.pm behave a bit
85           differently.  Ideally you should only use them in boolean context.
86
87           If not set, booleans are loaded as special perl variables
88           "PL_sv_yes" and "PL_sv_no", which have the disadvantage that they
89           are readonly, and you can't add those to an existing data structure
90           with pure perl.
91
92           If you simply need to load "perl booleans" that are true or false
93           in boolean context, you will be fine with the default setting.
94
95       $YAML::XS::Indent (since v0.76)
96           Default is 2.
97
98           Sets the number of spaces for indentation for "Dump".
99

USING YAML::XS WITH UNICODE

101       Handling unicode properly in Perl can be a pain. YAML::XS only deals
102       with streams of utf8 octets. Just remember this:
103
104           $perl = Load($utf8_octets);
105           $utf8_octets = Dump($perl);
106
107       There are many, many places where things can go wrong with unicode. If
108       you are having problems, use Devel::Peek on all the possible data
109       points.
110

LIBYAML

112       You can find out (since v.079) which libyaml version this module was
113       built with:
114
115             my $libyaml_version = YAML::XS::LibYAML::libyaml_version();
116

SEE ALSO

118       ·   YAML.pm
119
120       ·   YAML::Syck
121
122       ·   YAML::Tiny
123
124       ·   YAML::PP
125
126       ·   YAML::PP::LibYAML
127

AUTHOR

129       Ingy döt Net <ingy@cpan.org>
130
132       Copyright 2007-2019. Ingy döt Net.
133
134       This program is free software; you can redistribute it and/or modify it
135       under the same terms as Perl itself.
136
137       See <http://www.perl.com/perl/misc/Artistic.html>
138
139
140
141perl v5.30.0                      2019-08-22                       YAML::XS(3)
Impressum