in reply to Re^10: JSON::XS and blessings
in thread JSON::XS and blessings

In checking what I thought were reasonable assumptions, I found that JSON::PP's handling of booleans and JSON::XS's handling of booleans are simply incompatible.

use JSON::XS(); use JSON::PP(); JSON::XS->new()->encode( JSON::PP->new()->decode('[true]') ); __END__ encountered object '1', but neither allow_blessed nor convert_blessed +settings are enabled

Note that even enabling convert_blessed() won't help as JSON::PP generates booleans that don't even have a TO_JSON() method. [And enabling allow_blessed() would just turn true/false into null.]

Both modules could use some work on dealing with booleans.

- tye        

Replies are listed 'Best First'.
Re^12: JSON::XS and blessings (incompat)
by cshavit (Novice) on Oct 16, 2015 at 21:54 UTC
    Interesting!

    As for me, I'd be happy to have a boolAsInt method, such that

    JSON->new()->boolAsInt(1)->decode('[true]')

    would return [1].