manpagez: man pages & more
man YAML::XS(3)
Home | html | info | man
YAML::XS(3)           User Contributed Perl Documentation          YAML::XS(3)


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


           use YAML::XS;

           my $yaml = Dump [ 1..4 ];
           my $array = Load $yaml;


       Kirill Siminov's "libyaml" is arguably the best YAML implementation.
       The C library is written precisely to the YAML 1.1 specification. It
       was originally bound to Python and was later bound to Ruby.

       This module is a Perl XS binding to libyaml which offers Perl the best
       YAML support to date.

       This module exports the functions "Dump", "Load", "DumpFile" and
       "LoadFile". These functions are intended to work exactly like
       ""'s corresponding functions. Only "Load" and "Dump" are
       exported by default.


       $YAML::XS::LoadBlessed (since v0.69)
           Default: true. The default might be changed to false in the future.

           When set to false, it will not bless data into objects, which can
           be a security problem, when loading YAML from an untrusted source.
           It will silently ignore the tag and just load the data unblessed.

           In PyYAML, this is called SafeLoad.

           If set to true, it will load the following YAML as objects:

               local: !Foo::Bar [a]
               perl: !!perl/hash:Foo::Bar { a: 1 }
               regex: !!perl/regexp:Foo::Bar pattern

           If enabled supports deparsing and evaling of code blocks.

           When true (the default) strings that look like numbers but have not
           been numified will be quoted when dumping.

           This ensures leading that things like leading zeros and other
           formatting are preserved.

       $YAML::XS::Boolean (since v0.67)
           Default is undef.

           When set to "JSON::PP" or "boolean", the plain (unquoted) strings
           "true" and "false" will be loaded as "JSON::PP::Boolean" or
           "" objects. Those objects will be dumped again as plain
           "true" or "false".

           It will try to load JSON::PP or boolean and die if it can't be

           With that it's possible to add new "real" booleans to a data

                 local $YAML::XS::Boolean = "JSON::PP"; # or "boolean"
                 my $data = Load("booltrue: true");
                 $data->{boolfalse} = JSON::PP::false;
                 my $yaml = Dump($data);
                 # boolfalse: false
                 # booltrue: true

           It also lets booleans survive when loading YAML via YAML::XS and
           encode it in JSON via one of the various JSON encoders, which
           mostly support JSON::PP booleans.

           Please note that JSON::PP::Boolean and behave a bit
           differently.  Ideally you should only use them in boolean context.

           If not set, booleans are loaded as special perl variables
           "PL_sv_yes" and "PL_sv_no", which have the disadvantage that they
           are readonly, and you can't add those to an existing data structure
           with pure perl.

           If you simply need to load "perl booleans" that are true or false
           in boolean context, you will be fine with the default setting.


       Handling unicode properly in Perl can be a pain. YAML::XS only deals
       with streams of utf8 octets. Just remember this:

           $perl = Load($utf8_octets);
           $utf8_octets = Dump($perl);

       There are many, many places where things can go wrong with unicode. If
       you are having problems, use Devel::Peek on all the possible data


       o   YAML(3)

       o   YAML::Syck(3)

       o   YAML::Tiny(3)


       Ingy dA9|t Net <>


       Copyright 2007-2018. Ingy dA9|t Net.

       This program is free software; you can redistribute it and/or modify it
       under the same terms as Perl itself.

       See <>

perl v5.26.2                      2018-06-09                       YAML::XS(3)

yaml-libyaml 0.700.0 - Generated Thu Jun 14 16:04:38 CDT 2018
© 2000-2018
Individual documents may contain additional copyright information.