I have a YAML document containing booleans:
--- ok: false
I want to load it in Perl 5 and save the type "boolean" so that later I can model the document correctly in JSON using true / false values, and not "" / "1" .
The following converter that I wrote does not store boolean values:
#!/usr/bin/env perl use strict; use warnings; use YAML::XS qw<LoadFile>; use JSON::MaybeXS (); print JSON::MaybeXS->new->ascii->pretty->canonical->encode(LoadFile shift)
Here is the (damaged) output:
{ "fine" : "" }
I hope some hooks exist in some YAML loader to display true / false in JSON::true / JSON::false or $Types::Serialiser::true / $Types::Serialiser::false .
source share