The JSON module produce incorrect warning about Cpanel::JSON::XS not supporting indent_length. Recent versions of Cpanel supported this method, and the code dispatch the call to the Cpanel backend.
Error Message:
indent_length is not supported by Cpanel::JSON::XS. at ...
Minimal Code to replicate:
export PERL_JSON_BACKEND=Cpanel::JSON::XS
perl -e 'use JSON ; my $json = new JSON ; $json->indent_length(2)'
Output:
indent_length is not supported by Cpanel::JSON::XS. at -e line 1.
Suggessted Solution:
Code currently has hard-coded list of methods that are only available with JSON::PP
my @PPOnlyMethods = qw/
indent_length sort_by
allow_singlequote allow_bignum loose allow_barekey escape_slash as_nonblessed
Suggesting use can(...) to check for on the selected backend if the method will be suppored. At this point, Cpanel support indent_length and (limited) sort_by, allow_bignum and more.
The JSON module produce incorrect warning about Cpanel::JSON::XS not supporting
indent_length. Recent versions of Cpanel supported this method, and the code dispatch the call to the Cpanel backend.Error Message:
indent_length is not supported by Cpanel::JSON::XS. at ...Minimal Code to replicate:
Output:
Suggessted Solution:
Code currently has hard-coded list of methods that are only available with JSON::PP
Suggesting use can(...) to check for on the selected backend if the method will be suppored. At this point, Cpanel support
indent_lengthand (limited)sort_by,allow_bignumand more.