I have a JSON serializer/deserializer object that I use (using JSON.pm and JSON::XS) and I want to convert JSON boolean values like JSON::true and JSON::false to be the javascript false instead of the javascript string "false". I'm converting blessed references with a Universal method like this(taken from the JSON docs):
use JSON -convert_blessed_universally; use constant SERIALIZER => 'JSON'; *UNIVERSAL::TO_JSON = sub { my $b_obj = B::svref_2object( $_[0] ); return $b_obj->isa('B::HV') ? { %{ $_[0] } } : $b_obj->isa('B::AV') ? [ @{ $_[0] } ] : undef ; }; sub serialize{ my $self = shift; my $params = shift; my $json_obj = JSON->new->allow_nonref; my $serialize = $json_obj->allow_blessed->convert_blessed->encode( + $params ); return $serialize; }
The question is, where/how should I change the logic so that a $hash->{'true_false_value'} = JSON::false; is turned into a javascript true_false_value: false instead of true_false_value: "false"

In reply to JSON.pm returning "false" instead of false by josh803316

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.