Skip to content

Commit 6395021

Browse files
authored
Merge pull request #2692 from drgrice1/format-rendered-problem-json-conflict
Fix an issue with conflicting JSON modules in use in FormatRenderedProblem.pm.
2 parents 4970e0e + 0bfc8e0 commit 6395021

11 files changed

+10
-18
lines changed

bin/OPL-update-legacy

-2
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,6 @@ if($canopenfile) {
539539
}
540540
#### End of taxonomy/taxonomy2
541541

542-
use JSON;
543-
544542
#### Save the official taxonomy in json format
545543
my $webwork_htdocs = $ce->{webworkDirs}{htdocs};
546544
my $file = "$webwork_htdocs/DATA/tagging-taxonomy.json";

bin/OPLUtils.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use warnings;
1717
use File::Find::Rule;
1818
use File::Basename;
1919
use open qw/:std :utf8/;
20-
use JSON;
20+
use Mojo::JSON qw(encode_json);
2121

2222
our @EXPORT = ();
2323
our @EXPORT_OK =
@@ -373,7 +373,7 @@ sub build_library_textbook_tree {
373373
sub writeJSONtoFile {
374374
my ($data, $filename) = @_;
375375

376-
my $json = JSON->new->utf8->encode($data);
376+
my $json = encode_json($data);
377377
open my $fh, ">", $filename or die "Cannot open $filename";
378378
print $fh $json;
379379
close $fh;

bin/check_modules.pl

-2
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,6 @@ =head1 DESCRIPTION
107107
IO::Socket::SSL
108108
Iterator
109109
Iterator::Util
110-
JSON
111-
JSON::MaybeXS
112110
Locale::Maketext::Lexicon
113111
Locale::Maketext::Simple
114112
LWP::Protocol::https

bin/download-OPL-metadata-release.pl

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
use File::Path;
1212
use Archive::Tar;
1313
use Mojo::File;
14-
use JSON;
14+
use Mojo::JSON qw(decode_json);
1515

1616
BEGIN {
1717
use Mojo::File qw(curfile);
@@ -36,7 +36,7 @@ BEGIN
3636
File::Fetch->new(uri => 'https://api.github.com/repos/openwebwork/webwork-open-problem-library/releases/latest');
3737
my $file = $releaseDataFF->fetch(to => $ce->{webworkDirs}{tmp}) or die $releaseDataFF->error;
3838
my $path = Mojo::File->new($file);
39-
my $releaseData = JSON->new->utf8->decode($path->slurp);
39+
my $releaseData = decode_json($path->slurp);
4040
$path->remove;
4141

4242
my $releaseTag = $releaseData->{tag_name};

conf/defaults.config

+1-1
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,7 @@ ${pg}{modules} = [
13631363
[qw(PGcore PGalias PGresource PGloadfiles PGanswergroup PGresponsegroup Tie::IxHash)],
13641364
[qw(Locale::Maketext)],
13651365
[qw(WeBWorK::PG::Localize)],
1366-
[qw(JSON)],
1366+
[qw(Mojo::JSON)],
13671367
[qw(Rserve Class::Tiny IO::Handle)],
13681368
[qw(DragNDrop)],
13691369
[qw(Types::Serialiser)],

lib/Caliper/Sensor.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use WeBWorK::CourseEnvironment;
77
use WeBWorK::DB;
88
use WeBWorK::Debug;
99
use Data::Dumper;
10-
use JSON;
10+
use Mojo::JSON qw(encode_json);
1111
use Time::HiRes qw/gettimeofday/;
1212
use Date::Format;
1313

@@ -67,7 +67,7 @@ sub sendEvents {
6767
'data' => $event_chunk,
6868
};
6969

70-
my $json_payload = JSON->new->canonical->encode($envelope);
70+
my $json_payload = encode_json($envelope);
7171
# debug("Caliper event json_payload: " . $json_payload);
7272

7373
my $HTTPRequest = HTTP::Request->new(

lib/FormatRenderedProblem.pm

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ package FormatRenderedProblem;
2424
use strict;
2525
use warnings;
2626

27-
use JSON;
2827
use Digest::SHA qw(sha1_base64);
2928
use Mojo::Util qw(xml_escape);
3029
use Mojo::JSON qw(encode_json);
@@ -228,7 +227,7 @@ sub formatRenderedProblem {
228227
$output->{pg_version} = $ce->{PG_VERSION};
229228

230229
# Convert to JSON and render.
231-
return $ws->c->render(data => JSON->new->utf8(1)->encode($output));
230+
return $ws->c->render(data => encode_json($output));
232231
}
233232

234233
# Setup arnd render the appropriate template in the templates/RPCRenderFormats folder depending on the outputformat.

lib/WeBWorK/ContentGenerator/InstructorRPCHandler.pm

-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ error occurs, then the response will contain an "error" key.
3939
# was "instructor" only. Usage of all commands is based on permissions, and there have always been non-instructor users
4040
# that have some of these permissions. So this module and the corresponding route should really be renamed.
4141

42-
use JSON;
43-
4442
use WebworkWebservice;
4543

4644
sub initializeRoute ($c, $routeCaptures) {

lib/WeBWorK/Controller.pm

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ fields.
2525
=cut
2626

2727
use Encode;
28-
use JSON::MaybeXS;
2928

3029
use WeBWorK::Localize;
3130

lib/WeBWorK/Utils/Instructor.pm

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use strict;
2626
use warnings;
2727

2828
use File::Find;
29+
use Mojo::JSON qw(decode_json);
2930

3031
use WeBWorK::DB::Utils qw(initializeUserProblem);
3132
use WeBWorK::Debug;
@@ -642,7 +643,7 @@ sub loadSetDefListFile {
642643
$contents;
643644
};
644645

645-
return @{ JSON->new->decode($data) };
646+
return @{ decode_json($data) };
646647
}
647648

648649
return;

lib/WebworkWebservice/SetActions.pm

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ use strict;
2020
use warnings;
2121

2222
use Carp;
23-
use JSON;
2423
use Data::Structure::Util qw(unbless);
2524

2625
use WeBWorK::Utils qw(max);

0 commit comments

Comments
 (0)