in reply to Can not use JSON module
Following up on what tobyink and 1nickt said, in a recent distribution I wrote, I let the compiler decide whether to use JSON (XS) or JSON::PP which is already in the core. If JSON is not installed, it'll automatically fall back to the core JSON::PP.
BEGIN { # look for JSON::XS, and if not available, fall # back to JSON::PP to avoid requiring non-core modules my $json_ok = eval { require JSON::XS; JSON::XS->import; 1; }; if (! $json_ok){ require JSON::PP; JSON::PP->import; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Can not use JSON module
by choroba (Cardinal) on Jun 02, 2017 at 14:00 UTC | |
by hippo (Archbishop) on Jun 02, 2017 at 14:10 UTC | |
by choroba (Cardinal) on Jun 02, 2017 at 14:27 UTC | |
by hippo (Archbishop) on Jun 02, 2017 at 14:42 UTC | |
by stevieb (Canon) on Jun 02, 2017 at 14:02 UTC |