Created
August 2, 2010 19:39
-
-
Save xantus/505189 to your computer and use it in GitHub Desktop.
MojoX::JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package MojoX::JSON; | |
use Mojo::JSON; | |
our $SINGLETON; | |
BEGIN { | |
# install JSON::XS if you can! | |
eval 'use JSON();'; | |
eval ( $@ ? 'sub HAS_JSON(){ 0 }' : 'sub HAS_JSON(){ 1 }' ); | |
}; | |
sub singleton { | |
$SINGLETON ||= shift->new( @_ ); | |
} | |
sub new { | |
return HAS_JSON ? 'JSON'->new( @_[ 1 .. $#_ ] ) : Mojo::JSON->new( @_[ 1 .. $#_ ] ); | |
} | |
1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment