bc3-au has asked for the wisdom of the Perl Monks concerning the following question:
Due to the work I'm doing processing returned API data, I need bools decoded using JSON::decode to be numeric, rather than JSON::PP::Boolean.
CPAN docs are great, just use $json->boolean_values(0,1);
Unfortunately that method doesn't seem to be getting exported:
#!perl -lI'm using Debian packages for the libraries we have infrastructure teams maintaining our systems & having them update via CPAN causes issues However the modules do look correct.use 5.012; # strict, // use warnings; use JSON 4.0; use Data::Dumper; print "JSON::VERSION = $JSON::VERSION\n"; my $json = JSON->new; $json->boolean_values(0,1); test@BruceDEV:~$ perl Perl-Testing/JSON-boolean_values.pl JSON::VERSION = 4.02 Can't locate object method "boolean_values" via package "JSON" at Perl +-Testing/JSON-boolean_values.pl line 11.
Looking at the contents of /usr/share/perl5/JSON.pm I see this, so it looks like it's definitely the right module, although I'm a little suspicious as a number of the methods in the docs, including boolean_values don't seem to be exported.Debian GNU/Linux 10 ii libjson-perl 4.02000-1 + all module for manipulating JSON-formatted d +ata ii libjson-xs-perl 3.040-1+b1 + amd64 module for manipulating JSON-formatted d +ata (C/XS-accelerated)
Any pointers ?, I *really* don't want to move to using CPAN directly on these devices, given how they're maintained.package JSON; use strict; use Carp (); use Exporter; BEGIN { @JSON::ISA = 'Exporter' } @JSON::EXPORT = qw(from_json to_json jsonToObj objToJson encode_json d +ecode_json); BEGIN { $JSON::VERSION = '4.02'; $JSON::DEBUG = 0 unless (defined $JSON::DEBUG); $JSON::DEBUG = $ENV{ PERL_JSON_DEBUG } if exists $ENV{ PERL_JSON +_DEBUG }; } [...] =head2 boolean_values (since version 4.0) $json->boolean_values([$false, $true]) ($false, $true) = $json->get_boolean_values By default, JSON booleans will be decoded as overloaded C<$JSON::false> and C<$JSON::true> objects.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Issues using boolean_values in JSON v4.02
by kikuchiyo (Hermit) on Jun 14, 2023 at 09:32 UTC | |
by ikegami (Patriarch) on Jun 15, 2023 at 14:14 UTC | |
|
Re: Issues using boolean_values in JSON v4.02
by hv (Prior) on Jun 14, 2023 at 02:35 UTC | |
by ikegami (Patriarch) on Jun 15, 2023 at 04:20 UTC | |
by hv (Prior) on Jun 15, 2023 at 12:14 UTC |