in reply to Re^4: Making JSON::{PP,XS} not decode true/false to JSON::{PP,XS}::Boolean objects (source)
in thread Making JSON::{PP,XS} not decode true/false to JSON::{PP,XS}::Boolean objects

Thanks!

Since, for a boolean type, it is reasonable to implement it as a ref to a scalar (and that is how it has been done over and over in several different JSON modules), I'd just treat a reference to a scalar as a boolean. The only change required is using reftype() or $ref =~ /SCALAR/, as ref() returning exactly "SCALAR" is already handled that way.

- tye        

  • Comment on Re^5: Making JSON::{PP,XS} not decode true/false to JSON::{PP,XS}::Boolean objects (\$)
  • Download Code

Replies are listed 'Best First'.
Re^6: Making JSON::{PP,XS} not decode true/false to JSON::{PP,XS}::Boolean objects (\$)
by davido (Cardinal) on Oct 16, 2013 at 16:43 UTC

    Version 0.35 now treats a reference to a scalar as a Boolean so that users can encode, for example \0 and \1 as false and true. Tests and documentation have also been updated.

    $j->encode( { a => \1, b => \0 } ) # '{"a":true, "b":false}'

    Blessed refs work too.


    Dave