Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions META.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,14 @@
},
"runtime" : {
"recommends" : {
"JSON::XS" : "0"
"Cpanel::JSON::XS" : "0"
},
"requires" : {
"CGI" : "0",
"Class::Accessor::Lite" : "0",
"HTTP::Request" : "0",
"HTTP::Response" : "0",
"JSON" : "0",
"JSON::MaybeXS" : "0",
"LWP::UserAgent" : "0",
"Plack" : "0",
"Router::Simple" : "0",
Expand Down
4 changes: 2 additions & 2 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ requires 'CGI';
requires 'Class::Accessor::Lite';
requires 'HTTP::Request';
requires 'HTTP::Response';
requires 'JSON';
requires 'JSON::MaybeXS';
requires 'LWP::UserAgent';
requires 'Plack';
requires 'Router::Simple';
requires 'parent';
recommends 'JSON::XS';
recommends 'Cpanel::JSON::XS';

on build => sub {
requires 'ExtUtils::MakeMaker', '6.36';
Expand Down
4 changes: 2 additions & 2 deletions lib/JSON/RPC/Dispatch.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ sub new {
@args,
}, $class;
if (! $self->{coder}) {
require JSON;
$self->{coder} = JSON->new->utf8;
require JSON::MaybeXS;
$self->{coder} = JSON::MaybeXS::JSON()->new->utf8;
}
if (! $self->{parser}) {
$self->{parser} = JSON::RPC::Parser->new( coder => $self->coder )
Expand Down
8 changes: 4 additions & 4 deletions lib/JSON/RPC/Legacy/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
##############################################################################

use strict;
use JSON ();
use JSON::MaybeXS 'JSON';
use Carp ();

##############################################################################
Expand Down Expand Up @@ -62,7 +62,7 @@ sub AUTOLOAD {


sub create_json_coder {
JSON->new->allow_nonref->utf8;
JSON()->new->allow_nonref->utf8;
}


Expand Down Expand Up @@ -349,9 +349,9 @@ Setter/getter to L<LWP::UserAgent> object.
=item json

Setter/getter to the JSON coder object.
Default is L<JSON>, likes this:
The default is the backend returned by L<JSON::MaybeXS>, created like this:

$self->json( JSON->new->allow_nonref->utf8 );
$self->json( JSON()->new->allow_nonref->utf8 );

$json = $self->json;

Expand Down
8 changes: 4 additions & 4 deletions lib/JSON/RPC/Legacy/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
##############################################################################

use strict;
use JSON ();
use Carp ();

use HTTP::Request ();
Expand All @@ -14,6 +13,7 @@ use HTTP::Response ();
##############################################################################

package JSON::RPC::Legacy::Server;
use JSON::MaybeXS 'JSON';

my $JSONRPC_Procedure_Able;

Expand Down Expand Up @@ -43,7 +43,7 @@ BEGIN {


sub create_json_coder {
JSON->new->utf8; # assumes UTF8
JSON()->new->utf8; # assumes UTF8
}


Expand Down Expand Up @@ -569,9 +569,9 @@ An error code number in your procedure is an integer between 501 and 899.
=item json

Setter/Getter to json encoder/decoder object.
The default value is L<JSON> object in the below way:
The default value is a JSON serializer object as returned by L<JSON::MaybeXS> in the following manner:

JSON->new->utf8
JSON()->new->utf8

In your procedure, changes its behaviour.

Expand Down
7 changes: 4 additions & 3 deletions t/002_basic.t
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use warnings;
use Test::More;
use Plack::Test;
use HTTP::Request;
use JSON;
use JSON::MaybeXS;

BEGIN {
use_ok "JSON::RPC::Dispatch";
Expand All @@ -15,7 +15,8 @@ BEGIN {
subtest 'defaults' => sub {
my $dispatch = JSON::RPC::Dispatch->new();
if (ok $dispatch->coder) {
isa_ok $dispatch->coder, 'JSON';
my $json_backend = JSON::MaybeXS::JSON();
isa_ok $dispatch->coder, $json_backend;
}

if (ok $dispatch->router) {
Expand All @@ -28,7 +29,7 @@ subtest 'defaults' => sub {
};

subtest 'normal dispatch' => sub {
my $coder = JSON->new;
my $coder = JSON()->new;
my $router = Router::Simple->new;
$router->connect( blowup => {
handler => "Sum",
Expand Down
4 changes: 2 additions & 2 deletions t/003_parser.t
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use strict;
use Test::More;
use Plack::Request;
use JSON;
use JSON::MaybeXS 'to_json', 'JSON';

use_ok "JSON::RPC::Parser";
use_ok "JSON::RPC::Procedure";
Expand All @@ -12,7 +12,7 @@ subtest 'basic' => sub {
REQUEST_METHOD => "GET",
} );
my $parser = JSON::RPC::Parser->new(
coder => JSON->new,
coder => JSON()->new,
);

my $procedure = $parser->construct_from_req( $req );
Expand Down
3 changes: 2 additions & 1 deletion t/legacy/02_server.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ my $server = JSON::RPC::Legacy::Server->new;

isa_ok($server, 'JSON::RPC::Legacy::Server');

isa_ok($server->json, 'JSON');
my $json_backend = JSON::MaybeXS::JSON();
isa_ok($server->json, $json_backend);

my $test = JSON::RPC::Legacy::Server::Test->new;

Expand Down