Fix prototype mismatch warning for JSON functions. #182
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The prototypes used in RapidApp::JSON::MixedEncoder for encode_json()
and decode_json() match the respective prototypes in JSON::XS, but they
don't match the prototypes used for those functions in Cpanel::JSON::XS,
which JSON::MaybeXS will use in preference to JSON::XS.
This can be easily demonstrated by including both modules:
$ perl -MJSON::MaybeXS -MRapidApp::JSON::MixedEncoder -e 0$;$ ) vs ($) at /usr/share/perl/5.26/Exporter.pm line 66.$;$ $) vs ($) at /usr/share/perl/5.26/Exporter.pm line 66.
Prototype mismatch: sub main::encode_json (
at -e line 0.
Prototype mismatch: sub main::decode_json (
at -e line 0.
RapidApp uses Catalyst, which uses JSON::MaybeXS, causing this prototype
mismatch warning. This commit fixes this problem by using JSON::MaybeXS
where the JSON module was previously used, and changing the prototypes
for encode_json() and decode_json() in RapidApp::JSON::MixedEncoder to
match the prototypes in Cpanel::JSON::XS, rather than JSON::XS.
Note that this change means that using RapidApp::JSON::MixedEncoder with
either JSON::XS or JSON will now cause a prototype mismatch warning!