Skip to content

Commit

Permalink
Merge pull request #60 from tvroom/master
Browse files Browse the repository at this point in the history
Update to use JSON::MaybeXS instead of deprecated JSON::Any
  • Loading branch information
fayland committed Mar 6, 2015
2 parents 8080b5e + f4bf04d commit 3726dae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile.PL
Expand Up @@ -12,7 +12,7 @@ requires 'URI';
requires 'URI::Escape';
requires 'Moo';
requires 'Types::Standard';
requires 'JSON::Any';
requires 'JSON::MaybeXS';
# requires 'JSON::XS'; # avoid "Couldn't find a JSON package. Need XS, JSON, or DWIW"
#
requires 'LWP::UserAgent';
Expand Down
10 changes: 5 additions & 5 deletions lib/Net/GitHub/V3/Query.pm
Expand Up @@ -4,7 +4,7 @@ our $VERSION = '0.71';
our $AUTHORITY = 'cpan:FAYLAND';

use URI;
use JSON::Any;
use JSON::MaybeXS;
use MIME::Base64;
use LWP::UserAgent;
use HTTP::Request;
Expand Down Expand Up @@ -96,10 +96,10 @@ has 'ua' => (

has 'json' => (
is => 'ro',
isa => InstanceOf['JSON::Any'],
isa => InstanceOf['JSON::MaybeXS'],
lazy => 1,
default => sub {
return JSON::Any->new( utf8 => 1 );
return JSON::MaybeXS->new( utf8 => 1 );
}
);

Expand Down Expand Up @@ -143,7 +143,7 @@ sub query {
my $req = HTTP::Request->new( $request_method, $url );
$req->accept_decodable;
if ($data) {
my $json = $self->json->objToJson($data);
my $json = $self->json->encode($data);
print STDERR ">>> $data\n" if $ENV{NG_DEBUG} and $ENV{NG_DEBUG} > 1;
$req->content($json);
}
Expand All @@ -165,7 +165,7 @@ sub query {

if ($res->header('Content-Type') and $res->header('Content-Type') =~ 'application/json') {
my $json = $res->decoded_content;
$data = eval { $self->json->jsonToObj($json) };
$data = eval { $self->json->decode($json) };
unless ($data) {
# We tolerate bad JSON for errors,
# otherwise we just rethrow the JSON parsing problem.
Expand Down

0 comments on commit 3726dae

Please sign in to comment.