File tree Expand file tree Collapse file tree 8 files changed +22
-20
lines changed
Expand file tree Collapse file tree 8 files changed +22
-20
lines changed Original file line number Diff line number Diff line change 5252 },
5353 "runtime" : {
5454 "recommends" : {
55- "JSON::XS" : " 0"
55+ "Cpanel:: JSON::XS" : " 0"
5656 },
5757 "requires" : {
5858 "CGI" : " 0" ,
5959 "Class::Accessor::Lite" : " 0" ,
6060 "HTTP::Request" : " 0" ,
6161 "HTTP::Response" : " 0" ,
62- "JSON" : " 0" ,
62+ "JSON::MaybeXS " : " 0" ,
6363 "LWP::UserAgent" : " 0" ,
6464 "Plack" : " 0" ,
6565 "Router::Simple" : " 0" ,
Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ requires 'CGI';
22requires ' Class::Accessor::Lite' ;
33requires ' HTTP::Request' ;
44requires ' HTTP::Response' ;
5- requires ' JSON' ;
5+ requires ' JSON::MaybeXS ' ;
66requires ' LWP::UserAgent' ;
77requires ' Plack' ;
88requires ' Router::Simple' ;
99requires ' parent' ;
10- recommends ' JSON::XS' ;
10+ recommends ' Cpanel:: JSON::XS' ;
1111
1212on build => sub {
1313 requires ' ExtUtils::MakeMaker' , ' 6.36' ;
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ sub new {
2424 @args ,
2525 }, $class ;
2626 if (! $self -> {coder }) {
27- require JSON;
28- $self -> {coder } = JSON-> new-> utf8;
27+ require JSON::MaybeXS ;
28+ $self -> {coder } = JSON::MaybeXS::JSON() -> new-> utf8;
2929 }
3030 if (! $self -> {parser }) {
3131 $self -> {parser } = JSON::RPC::Parser-> new( coder => $self -> coder )
Original file line number Diff line number Diff line change 44# #############################################################################
55
66use strict;
7- use JSON () ;
7+ use JSON::MaybeXS ' JSON ' ;
88use Carp ();
99
1010# #############################################################################
@@ -62,7 +62,7 @@ sub AUTOLOAD {
6262
6363
6464sub create_json_coder {
65- JSON-> new-> allow_nonref-> utf8;
65+ JSON() -> new-> allow_nonref-> utf8;
6666}
6767
6868
@@ -349,9 +349,9 @@ Setter/getter to L<LWP::UserAgent> object.
349349=item json
350350
351351Setter/getter to the JSON coder object.
352- Default is L<JSON> , likes this:
352+ The default is the backend returned by L<JSON::MaybeXS > , created like this:
353353
354- $self->json( JSON->new->allow_nonref->utf8 );
354+ $self->json( JSON() ->new->allow_nonref->utf8 );
355355
356356 $json = $self->json;
357357
Original file line number Diff line number Diff line change 44# #############################################################################
55
66use strict;
7- use JSON ();
87use Carp ();
98
109use HTTP::Request ();
@@ -14,6 +13,7 @@ use HTTP::Response ();
1413# #############################################################################
1514
1615package JSON::RPC::Legacy::Server ;
16+ use JSON::MaybeXS ' JSON' ;
1717
1818my $JSONRPC_Procedure_Able ;
1919
@@ -43,7 +43,7 @@ BEGIN {
4343
4444
4545sub create_json_coder {
46- JSON-> new-> utf8; # assumes UTF8
46+ JSON() -> new-> utf8; # assumes UTF8
4747}
4848
4949
@@ -569,9 +569,9 @@ An error code number in your procedure is an integer between 501 and 899.
569569=item json
570570
571571Setter/Getter to json encoder/decoder object.
572- The default value is L<JSON> object in the below way :
572+ The default value is a JSON serializer object as returned by L<JSON::MaybeXS> in the following manner :
573573
574- JSON->new->utf8
574+ JSON() ->new->utf8
575575
576576In your procedure, changes its behaviour.
577577
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use warnings;
33use Test::More;
44use Plack::Test;
55use HTTP::Request;
6- use JSON;
6+ use JSON::MaybeXS ;
77
88BEGIN {
99 use_ok " JSON::RPC::Dispatch" ;
@@ -15,7 +15,8 @@ BEGIN {
1515subtest ' defaults' => sub {
1616 my $dispatch = JSON::RPC::Dispatch-> new();
1717 if (ok $dispatch -> coder) {
18- isa_ok $dispatch -> coder, ' JSON' ;
18+ my $json_backend = JSON::MaybeXS::JSON();
19+ isa_ok $dispatch -> coder, $json_backend ;
1920 }
2021
2122 if (ok $dispatch -> router) {
@@ -28,7 +29,7 @@ subtest 'defaults' => sub {
2829};
2930
3031subtest ' normal dispatch' => sub {
31- my $coder = JSON-> new;
32+ my $coder = JSON() -> new;
3233 my $router = Router::Simple-> new;
3334 $router -> connect ( blowup => {
3435 handler => " Sum" ,
Original file line number Diff line number Diff line change 11use strict;
22use Test::More;
33use Plack::Request;
4- use JSON;
4+ use JSON::MaybeXS ' to_json ' , ' JSON ' ;
55
66use_ok " JSON::RPC::Parser" ;
77use_ok " JSON::RPC::Procedure" ;
@@ -12,7 +12,7 @@ subtest 'basic' => sub {
1212 REQUEST_METHOD => " GET" ,
1313 } );
1414 my $parser = JSON::RPC::Parser-> new(
15- coder => JSON-> new,
15+ coder => JSON() -> new,
1616 );
1717
1818 my $procedure = $parser -> construct_from_req( $req );
Original file line number Diff line number Diff line change @@ -8,7 +8,8 @@ my $server = JSON::RPC::Legacy::Server->new;
88
99isa_ok($server , ' JSON::RPC::Legacy::Server' );
1010
11- isa_ok($server -> json, ' JSON' );
11+ my $json_backend = JSON::MaybeXS::JSON();
12+ isa_ok($server -> json, $json_backend );
1213
1314my $test = JSON::RPC::Legacy::Server::Test-> new;
1415
You can’t perform that action at this time.
0 commit comments