title: How to preserve boolean type from YAML document in Perl 5?
body: <p>I have a YAML document that contains boolean values:</p>
  
  <pre><code>---
  ok: false
  </code></pre>
  
  <p>I want to load it in Perl 5 and preserve the 'boolean' type to be able later to serialize the document properly to JSON using <code>true</code>/<code>false</code> values, not <code>""</code>/<code>"1"</code>.</p>
  
  <p>The following converter I wrote fails to preserve booleans:</p>
  
  <pre><code>#!/usr/bin/env perl
  
  use strict;
  use warnings;
  
  use YAML::XS qw&lt;LoadFile&gt;;
  use JSON::MaybeXS ();
  
  print JSON::MaybeXS-&gt;new-&gt;ascii-&gt;pretty-&gt;canonical-&gt;encode(LoadFile shift)
  </code></pre>
  
  <p>Here is the (corrupted) output:</p>
  
  <pre><code>{
     "fine" : ""
  }
  </code></pre>
  
  <p>I hope some hooks exist in some YAML loader to map <code>true</code>/<code>false</code> to <code>JSON::true</code>/<code>JSON::false</code> or <code>$Types::Serialiser::true</code>/<code>$Types::Serialiser::false</code>.</p>