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 52
52
},
53
53
"runtime" : {
54
54
"recommends" : {
55
- "JSON::XS" : " 0"
55
+ "Cpanel:: JSON::XS" : " 0"
56
56
},
57
57
"requires" : {
58
58
"CGI" : " 0" ,
59
59
"Class::Accessor::Lite" : " 0" ,
60
60
"HTTP::Request" : " 0" ,
61
61
"HTTP::Response" : " 0" ,
62
- "JSON" : " 0" ,
62
+ "JSON::MaybeXS " : " 0" ,
63
63
"LWP::UserAgent" : " 0" ,
64
64
"Plack" : " 0" ,
65
65
"Router::Simple" : " 0" ,
Original file line number Diff line number Diff line change @@ -2,12 +2,12 @@ requires 'CGI';
2
2
requires ' Class::Accessor::Lite' ;
3
3
requires ' HTTP::Request' ;
4
4
requires ' HTTP::Response' ;
5
- requires ' JSON' ;
5
+ requires ' JSON::MaybeXS ' ;
6
6
requires ' LWP::UserAgent' ;
7
7
requires ' Plack' ;
8
8
requires ' Router::Simple' ;
9
9
requires ' parent' ;
10
- recommends ' JSON::XS' ;
10
+ recommends ' Cpanel:: JSON::XS' ;
11
11
12
12
on build => sub {
13
13
requires ' ExtUtils::MakeMaker' , ' 6.36' ;
Original file line number Diff line number Diff line change @@ -24,8 +24,8 @@ sub new {
24
24
@args ,
25
25
}, $class ;
26
26
if (! $self -> {coder }) {
27
- require JSON;
28
- $self -> {coder } = JSON-> new-> utf8;
27
+ require JSON::MaybeXS ;
28
+ $self -> {coder } = JSON::MaybeXS::JSON() -> new-> utf8;
29
29
}
30
30
if (! $self -> {parser }) {
31
31
$self -> {parser } = JSON::RPC::Parser-> new( coder => $self -> coder )
Original file line number Diff line number Diff line change 4
4
# #############################################################################
5
5
6
6
use strict;
7
- use JSON () ;
7
+ use JSON::MaybeXS ' JSON ' ;
8
8
use Carp ();
9
9
10
10
# #############################################################################
@@ -62,7 +62,7 @@ sub AUTOLOAD {
62
62
63
63
64
64
sub create_json_coder {
65
- JSON-> new-> allow_nonref-> utf8;
65
+ JSON() -> new-> allow_nonref-> utf8;
66
66
}
67
67
68
68
@@ -349,9 +349,9 @@ Setter/getter to L<LWP::UserAgent> object.
349
349
=item json
350
350
351
351
Setter/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:
353
353
354
- $self->json( JSON->new->allow_nonref->utf8 );
354
+ $self->json( JSON() ->new->allow_nonref->utf8 );
355
355
356
356
$json = $self->json;
357
357
Original file line number Diff line number Diff line change 4
4
# #############################################################################
5
5
6
6
use strict;
7
- use JSON ();
8
7
use Carp ();
9
8
10
9
use HTTP::Request ();
@@ -14,6 +13,7 @@ use HTTP::Response ();
14
13
# #############################################################################
15
14
16
15
package JSON::RPC::Legacy::Server ;
16
+ use JSON::MaybeXS ' JSON' ;
17
17
18
18
my $JSONRPC_Procedure_Able ;
19
19
@@ -43,7 +43,7 @@ BEGIN {
43
43
44
44
45
45
sub create_json_coder {
46
- JSON-> new-> utf8; # assumes UTF8
46
+ JSON() -> new-> utf8; # assumes UTF8
47
47
}
48
48
49
49
@@ -569,9 +569,9 @@ An error code number in your procedure is an integer between 501 and 899.
569
569
=item json
570
570
571
571
Setter/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 :
573
573
574
- JSON->new->utf8
574
+ JSON() ->new->utf8
575
575
576
576
In your procedure, changes its behaviour.
577
577
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use warnings;
3
3
use Test::More;
4
4
use Plack::Test;
5
5
use HTTP::Request;
6
- use JSON;
6
+ use JSON::MaybeXS ;
7
7
8
8
BEGIN {
9
9
use_ok " JSON::RPC::Dispatch" ;
@@ -15,7 +15,8 @@ BEGIN {
15
15
subtest ' defaults' => sub {
16
16
my $dispatch = JSON::RPC::Dispatch-> new();
17
17
if (ok $dispatch -> coder) {
18
- isa_ok $dispatch -> coder, ' JSON' ;
18
+ my $json_backend = JSON::MaybeXS::JSON();
19
+ isa_ok $dispatch -> coder, $json_backend ;
19
20
}
20
21
21
22
if (ok $dispatch -> router) {
@@ -28,7 +29,7 @@ subtest 'defaults' => sub {
28
29
};
29
30
30
31
subtest ' normal dispatch' => sub {
31
- my $coder = JSON-> new;
32
+ my $coder = JSON() -> new;
32
33
my $router = Router::Simple-> new;
33
34
$router -> connect ( blowup => {
34
35
handler => " Sum" ,
Original file line number Diff line number Diff line change 1
1
use strict;
2
2
use Test::More;
3
3
use Plack::Request;
4
- use JSON;
4
+ use JSON::MaybeXS ' to_json ' , ' JSON ' ;
5
5
6
6
use_ok " JSON::RPC::Parser" ;
7
7
use_ok " JSON::RPC::Procedure" ;
@@ -12,7 +12,7 @@ subtest 'basic' => sub {
12
12
REQUEST_METHOD => " GET" ,
13
13
} );
14
14
my $parser = JSON::RPC::Parser-> new(
15
- coder => JSON-> new,
15
+ coder => JSON() -> new,
16
16
);
17
17
18
18
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;
8
8
9
9
isa_ok($server , ' JSON::RPC::Legacy::Server' );
10
10
11
- isa_ok($server -> json, ' JSON' );
11
+ my $json_backend = JSON::MaybeXS::JSON();
12
+ isa_ok($server -> json, $json_backend );
12
13
13
14
my $test = JSON::RPC::Legacy::Server::Test-> new;
14
15
You can’t perform that action at this time.
0 commit comments