YAML-Safe

 view release on metacpan or  search on metacpan

Safe.pm  view on Meta::CPAN

SafeClass set.

=item C<encoding>
=item C<get_encoding>

Default "utf8"

Set to "any", "utf8", "utf16le" or "utf16be".

=item C<boolean>
=item C<get_boolean>

Set to "JSON::PP" or "boolean" to enable or 0 to disable.  Encodes
true and false to the respective classes. It will try to load
L<JSON::PP> or L<boolean> and die if it can't be loaded.

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

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

Please note that JSON::PP::Boolean and boolean.pm behave a bit differently.
Ideally you should only use them in boolean context.
Setting a boolean() class is only possible on a perl since v5.8.9. It will die
on older perls.

If not set, booleans are loaded as special perl variables C<PL_sv_yes> and
C<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.

=item C<safemode>
=item C<get_safemode>

Default 0

If enabled by using the the Safe methods restrict the blessing only for
the set of registered classes or tags starting with "perl/".

=back

=head2 Loader Options

via getter and setter methods.

=over

=item C<nonstrict>
=item C<get_nonstrict>

If enabled permits certain reader errors to loosely match other YAML
module semantics. In detail: Allow B<"control characters are not
allowed"> with while parsing a quoted scalar found unknown escape
character. Note that any error is stored and returned, just not
immediately. This is needed for cpan distroprefs.

However the reader error B<"invalid trailing UTF-8 octet"> and all
other utf8 strictness violations are still fatal.

And if the structure of the YAML document cannot be parsed, i.e. a
required value consists only of invalid control characters, the loader
returns an error, unlike with non-strict YAML modules.

=item C<loadcode>
=item C<get_loadcode>

Turns on deparsing and evaling of code blocks in the loader.

=back

=head2 Dumper Options

via globals variables or as optional getter and setter methods.

=over

=item C<dumpcode>
=item C<get_dumpcode>

If enabled supports Dump of CV code blocks via
C<YAML::Safe::coderef2text()>.

=item C<quotenum>
=item C<get_quotenum>

Default: enabled.

If enabled 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.

=item C<noindentmap>
=item C<get_noindentmap>

If enabled fallback to the old C<YAML::Safe> behavior to omit the
indentation of map keys, which arguably violates the first YAML spec
(L<https://yaml.org/spec/1.0/#id2566128>), is different to most other
YAML libraries and causes older C<YAML.pm> to fail.

Disabled

     authors:
       - this author

Enabled

     authors:
     - this author

=item C<indent>
=item C<get_indent>

Default 2.
Valid values are from 1 - 10.



( run in 1.182 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )