Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^11: JSON::XS and blessings (incompat)

by tye (Sage)
on Oct 16, 2015 at 15:01 UTC ( [id://1145125]=note: print w/replies, xml ) Need Help??


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].

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1145125]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2024-04-18 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found