in reply to Issues using boolean_values in JSON v4.02

Based on the list of installed Debian packages you've posted:

Debian GNU/Linux 10 ii libjson-perl 4.02000-1 all m +odule for manipulating JSON-formatted data ii libjson-xs-perl 3.040-1+b1 amd64 m +odule for manipulating JSON-formatted data (C/XS-accelerated)

It's likely that the problem is that the JSON::XS module is installed, so JSON wants to use it, but it is too old (3.040), so it doesn't have the boolean_values method.

The best solution would be upgrading JSON::XS to 4.0 or newer, but this may be problematic if there is no Debian package available for your OS version.

Alternatively, you could force JSON to use the JSON::PP backend, which should support the boolean_values method, at the expense of being slower.

By the way, you could probably ditch the JSON module altogether and use either JSON::PP or JSON::XS explicitly, because it's only a convoluted and slow wrapper with little to no useful new functionality.

Replies are listed 'Best First'.
Re^2: Issues using boolean_values in JSON v4.02
by ikegami (Patriarch) on Jun 15, 2023 at 14:14 UTC

    It's not slow. Because it uses inheritance, it's just as fast as not using it (other than the one time per process setup cost).

    The reason I avoid it is because it defaults to JSON::PP. Your program could be orders of magnitude slower than required without any feedback that this is the case, just because you forgot to install the faster back end.

    And also because it uses JSON::XS instead of Cpanel::JSON::XS. The author of JSON::XS is very contrary, and insists on keeping JSON::XS thread-unsafe, yet most Perl builds are threaded builds. I don't need this drama associated with that author.

    (JSON will work with Cpanel::JSON::XS, but you have to explicitly tell it to.)