Skip to content

Commit 23dfb21

Browse files
authored
Merge pull request #959 from metacpan/haarg/cpanel-json-xs
convert uses of JSON to Cpanel::JSON::XS
2 parents 3510264 + f71ea6c commit 23dfb21

File tree

5 files changed

+5
-8
lines changed

5 files changed

+5
-8
lines changed

bin/convert_authors.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,6 @@
8585
unlink $file;
8686
(my $base = $file) =~ s/^(.*)\/.*?$/$1/;
8787
open FILE, '>', "$base/author-1.0.json";
88-
print FILE JSON->new->pretty->encode( $raw );
88+
print FILE Cpanel::JSON::XS->new->pretty->encode( $raw );
8989
close FILE;
9090
}

lib/Catalyst/Action/Deserialize/MetaCPANSanitizedJSON.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ around execute => sub {
3939
if ( my $source = delete $params->{source} ) {
4040

4141
# NOTE: merge $controller->{json_options} if we ever use it
42-
my $json = JSON->new->utf8;
42+
my $json = Cpanel::JSON::XS->new->utf8;
4343

4444
# if it decodes
4545
if ( try { $source = $json->decode($source); } ) {

lib/MetaCPAN/Script/Release.pm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ package MetaCPAN::Script::Release;
33
use strict;
44
use warnings;
55

6-
BEGIN {
7-
$ENV{PERL_JSON_BACKEND} = 'JSON::XS';
8-
}
9-
106
use CPAN::DistnameInfo ();
117
use File::Find::Rule ();
128
use File::stat ();

lib/MetaCPAN/Server/View/JSONP.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sub process {
2121
my $content_type = $c->res->content_type;
2222
return 1 if ( $content_type eq 'text/javascript' );
2323
if ( $content_type ne 'application/json' ) {
24-
$body = JSON->new->allow_nonref->ascii->encode($body);
24+
$body = Cpanel::JSON::XS->new->allow_nonref->ascii->encode($body);
2525
}
2626
$c->res->body("/**/$cb($body);");
2727
return 1;

t/server/controller/source.t

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use strict;
22
use warnings;
33
use lib 't/lib';
44

5+
use Cpanel::JSON::XS ();
56
use MetaCPAN::Server::Test;
67
use MetaCPAN::TestHelpers;
78
use Test::More;
@@ -96,7 +97,7 @@ test_psgi app, sub {
9697
);
9798
ok(
9899
my $jsdata
99-
= JSON->new->allow_nonref->decode($function_args),
100+
= Cpanel::JSON::XS->new->allow_nonref->decode($function_args),
100101
'decode json'
101102
);
102103
is( $jsdata, $manifest, 'JSONP-wrapped manifest' );

0 commit comments

Comments
 (0)