Test::Smoke::Util::LoadAJSON - A JSON:PP/JSON::XS Factory Class


    use Test::Smoke::Util::LoadAJSON;
    my $json = Test::Smoke::Util::LoadAJSON->new->utf8->pretty->encode(\%data);


This is purely a fallback factory class that helps keep our code clean.

This is for people with a clean perl 5.14+ install that have JSON::PP but not JSON. Also people that installed JSON::XS on a pre-5.14 system.

Also checks for $ENV{PERL_JSON_BACKEND} to force either of the two.

my $class = Test::Smoke::Util::LoadAJSON->find_base_class()

On success returns one of: JSON::PP, JSON::XS

Returns undef on failure.

my $obj = Test::Smoke::Util::LoadAJSON->new(<arguments>)

If a base class is found, will return an instantiated object.

This will die() if no base class could be found.


(c) 2014, All rights reserved.

  * Abe Timmerman <>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.