YAML-Safe
view release on metacpan or search on metacpan
via getter and setter methods.
"enablecode" =item "get_enablecode"
If enabled turns on handling of code blocks for the loader and
dumper. It sets both the "loadcode" and "dumpcode" option.
"disableblessed" =item "get_disableblessed"
Default 0
If set, i.e. blessed is disabled, all blessed data for the Loader
and Dumper is unblessed. This is similar to the Safe methods without
any SafeClass set.
"encoding" =item "get_encoding"
Default "utf8"
Set to "any", "utf8", "utf16le" or "utf16be".
"boolean" =item "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
JSON::PP or 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
"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.
"safemode" =item "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/".
Loader Options
via getter and setter methods.
"nonstrict" =item "get_nonstrict"
If enabled permits certain reader errors to loosely match other YAML
module semantics. In detail: Allow "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 "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.
"loadcode" =item "get_loadcode"
Turns on deparsing and evaling of code blocks in the loader.
Dumper Options
via globals variables or as optional getter and setter methods.
"dumpcode" =item "get_dumpcode"
If enabled supports Dump of CV code blocks via
YAML::Safe::coderef2text().
"quotenum" =item "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.
"noindentmap" =item "get_noindentmap"
If enabled fallback to the old "YAML::Safe" behavior to omit the
indentation of map keys, which arguably violates the first YAML spec
(<https://yaml.org/spec/1.0/#id2566128>), is different to most other
YAML libraries and causes older "YAML.pm" to fail.
Disabled
authors:
- this author
Enabled
authors:
- this author
"indent" =item "get_indent"
Default 2. Valid values are from 1 - 10.
"wrapwidth" =item "get_wrapwidth"
Default 80
Control text wrapping.
"canonical" =item "get_canonical"
Default: disabled.
Enable to sort map keys.
"unicode" =item "get_unicode"
Default 1
Set to undef or 0 to disallow unescaped non-ASCII characters. e.g.
"YAML::Safe-"new->unicode(0)>
( run in 0.503 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )