Skip to content

JSON complain Cpanel::JSON indent_length not supported by Cpanel::JSON::XS #63

Description

@yairlenga

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions