This line
my $json = new JSON(autoconv => 0); # <-- line X
raises this error
Usage: JSON::XS::new(klass) at (...) line X
What’s wrong?
It’s a follow up to my question Is there a way to force quotation of numbers in JSON 1.x Perl module?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The API for the JSON module changed substantially between 1.15 and 2.00. Code written for JSON 1.x won’t necessarily work with JSON 2.x. In particular, the 1.x constructor took optional parameters. The 2.x constructor takes no parameters; instead, you use mutator functions after construction.
If you must support both JSON 1.x and 2.x for some reason, you’ll need to check if
JSON->VERSION < 2(actuallyJSON->VERSION < 1.99if you count the development releases of the 2.x API) and have two versions of your code, one for the 1.x API and one for 2.x.