develooper Front page | perl.perl5.porters | Postings from December 2021

Noisy redefines for JSON

Thread Next
From:
H.Merijn Brand
Date:
December 17, 2021 09:20
Subject:
Noisy redefines for JSON
Message ID:
20211217102002.6fc46104@pc09
Given that more and more data-exchange is happening with JSON, and that
JSON is core support, we should acknowledge that different projects use
different modules to parse/generate JSON and that (sub-(sub-))modules
might use/require a different version of a JSON parser than the
top-level script or any of the modules used for a project.

I was bitten by this when one project used JSON::XS (or
Cpanel::JSON::XS) under the hood, and and my own script used JSON::PP
(I did only need to parse a very small json struct and speed was not
important, and there was a small chance that this script was to be used
on a system where one of the XS variants was not available).

Things get more confused if people use JSON which would choose the ::XS
variant if available.

So, where should I report this behavior:

$ perl -MJSON::PP -MCpanel::JSON::XS -wE'say encode_json ({})'
Subroutine main::encode_json redefined at /pro/lib/perl5/5.34.0/Exporter.pm line 63.
 at -e line 0.
Prototype mismatch: sub main::encode_json ($) vs ($;$) at /pro/lib/perl5/5.34.0/Exporter.pm line 63.
 at -e line 0.
Subroutine main::decode_json redefined at /pro/lib/perl5/5.34.0/Exporter.pm line 63.
 at -e line 0.
Prototype mismatch: sub main::decode_json: none vs ($;$$) at /pro/lib/perl5/5.34.0/Exporter.pm line 63.
 at -e line 0.
Subroutine main::to_json redefined at /pro/lib/perl5/5.34.0/Exporter.pm line 63.
 at -e line 0.
Prototype mismatch: sub main::to_json ($) vs ($@) at /pro/lib/perl5/5.34.0/Exporter.pm line 63.
 at -e line 0.
Subroutine main::from_json redefined at /pro/lib/perl5/5.34.0/Exporter.pm line 63.
 at -e line 0.
Prototype mismatch: sub main::from_json ($) vs ($@) at /pro/lib/perl5/5.34.0/Exporter.pm line 63.
 at -e line 0.
{}

Which is to say the least annoying.

In the script at hand, I disabled the default import and used the OO
version to get rid of the warnings

-- 
H.Merijn Brand  https://tux.nl   Perl Monger   http://amsterdam.pm.org/
using perl5.00307 .. 5.33        porting perl5 on HP-UX, AIX, and Linux
https://tux.nl/email.html http://qa.perl.org https://www.test-smoke.org
                           

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About