in reply to How do I make the JSON module convert true/false to 1/0 instead of a blessed Boolean object?
Use boolean_values
Thanks, that looks like what I should be doing all right.
But doing this:
use JSON; my $j = JSON->new(); $j->boolean_values( 1, 0 ); [download]
Gets me Can't locate object method "boolean_values" via package "JSON"
What am I doing wrong?
grepping CPAN it seems the method ships with JSON::PP and you can read about it
# Note that JSON version 2.0 and above will automatically use # JSON::XS or JSON::PP, so you should be able to just: use JSON; [download]
This probably means you have also JSON::XS installed and it is loaded first
L*
Both JSON::PP and JSON::XS support boolean_values, and the error message said the method wasn't found in JSON, not JSON::XS.
works fine for me, JSON v4.03, JSON::PP v4.06
Are you using version 4+?
I was using the very latest JSON, but not the very latest JSON::PP, so that's a factor. Upgrading JSON::PP and specifically using that has fixed it.