makamaka / JSON

perl implementation of JSON encoder/decoder
42 stars 40 forks source link

backend detection/handling should be improved #32

Closed charsbar closed 8 years ago

charsbar commented 8 years ago

Any backend should be accepted, as long as it is compatible with JSON::XS/JSON::PP. It's also better to use JSON::Backend::(XS|PP) as a backend wrapper, instead of using the backend module directly, so that we don't need to care much about the name of the actual backend.

See also: https://rt.cpan.org/Ticket/Display.html?id=94784

charsbar commented 8 years ago

done around since https://github.com/makamaka/JSON/commit/966acfa3a0a19fcd2988939cd95c50472e1705f5

pali commented 7 years ago

Can you describe or document how to use custom JSON module implementation with JSON.pm? I'm not able to understand it from referenced commit 966acfa.

pali commented 7 years ago

Ok, now I found out how. E.g. Cpanel::JSON::XS can be loaded by:

BEGIN { $ENV{PERL_JSON_BACKEND} = "Cpanel::JSON::XS" };
use JSON 2.91_01;
...
karenetheridge commented 5 years ago

Please reopen this ticket -- it is not possible to set PERL_JSON_BACKEND to any other module.

$ PERL_JSON_BACKEND=Cpanel::JSON::XS perl -MJSON -e1
The value of environmental variable 'PERL_JSON_BACKEND' is invalid. at -e line 0.
Compilation failed in require.
BEGIN failed--compilation aborted.
charsbar commented 5 years ago

@karenetheridge VERSIONs of JSON and Cpanel::JSON::XS?

cf https://travis-ci.org/charsbar/JSON/builds/558053920

karenetheridge commented 5 years ago

I saw this with perl 5.16.3, JSON 2.90, Cpanel::JSON::XS 3.0115.

I see that 2.91_01 added the ability to use more backends; sorry!