anyway), C<strict_arrays> will produce an error when encountering arrays with
heterogenous types.
+=item no_string_guessing
+
+When encoding a Perl scalar it is not always clear what the TOML type
+of the value is supposed to be. By default, C<TOML::Tiny> will, for
+unblessed scalars, guess based on the scalar's appearance. Strings
+that look like numbers, or like datetimes, will be encoded as such.
+
+With no_string_guessing, C<TOML::Tiny> will look at the perl innards
+to find the currently stored value type. If it is a number, the
+scalar will be encoded as a number. If it's a string, as a string.
+Dates and times which weren't built with DateTime come out as strings.
+
+Specifying C<inflate_float>, C<inflate_integer>, and
+C<inflate_datetime> is likely to be helpful with this option.
+
=back
=head2 decode
my ($self, $data) = @_;
TOML::Tiny::Writer::to_toml($data,
strict_arrays => $self->{strict_arrays},
+ no_string_guessing => $self->{no_string_guessing},
);
}
anyway), C<strict_arrays> will produce an error when encountering arrays with
heterogenous types.
+=item no_string_guessing
+
+When encoding a Perl scalar it is not always clear what the TOML type
+of the value is supposed to be. By default, C<TOML::Tiny> will, for
+unblessed scalars, guess based on the scalar's appearance. Strings
+that look like numbers, or like datetimes, will be encoded as such.
+
+With no_string_guessing, C<TOML::Tiny> will look at the perl innards
+to find the currently stored value type. If it is a number, the
+scalar will be encoded as a number. If it's a string, as a string.
+Dates and times which weren't built with DateTime come out as strings.
+
+Specifying C<inflate_float>, C<inflate_integer>, and
+C<inflate_datetime> is likely to be helpful with this option.
+
=back
=head2 decode
my @KEYS;
+use B qw( svref_2object SVf_IOK SVf_NOK );
+
sub to_toml {
my $data = shift;
my %param = @_;
return $data->bnstr;
}
+ when (!! $param{no_string_guessing}) {
+ # Thanks to ikegami on Stack Overflow for the trick!
+ # https://stackoverflow.com/questions/12686335/how-to-tell-apart-numeric-scalars-and-string-scalars-in-perl/12693984#12693984
+
+ my $sv = svref_2object(\$data);
+ my $svflags = $sv->FLAGS;
+
+ if ($svflags & (SVf_IOK | SVf_NOK)) {
+ return $data;
+ } else {
+ return to_toml_string($data);
+ }
+ }
+
when ('') {
for ($data) {
when (looks_like_number($_)) {