Skip to content
Merged
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
2 changes: 0 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ jobs:
libencode-perl \
libgd-perl \
libhtml-parser-perl \
libjson-perl \
libjson-xs-perl \
liblocale-maketext-lexicon-perl \
libmojolicious-perl \
libtest2-suite-perl \
Expand Down
2 changes: 1 addition & 1 deletion conf/pg_config.dist.yml
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ modules:
- ['Tie::IxHash']
- ['Locale::Maketext']
- ['WeBWorK::PG::Localize']
- [JSON]
- ['Mojo::JSON']
- ['Class::Tiny']
- ['IO::Handle']
- ['Rserve']
Expand Down
3 changes: 1 addition & 2 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ on runtime => sub {
requires 'GD';
requires 'HTML::Entities';
requires 'HTML::Parser';
requires 'JSON';
requires 'JSON::XS';
requires 'Mojo::JSON';
requires 'Locale::Maketext';
requires 'Locale::Maketext::Lexicon';
requires 'Mojolicious';
Expand Down
2 changes: 0 additions & 2 deletions docker/pg.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ RUN apt-get update \
libencode-perl \
libgd-perl \
libhtml-parser-perl \
libjson-perl \
libjson-xs-perl \
liblocale-maketext-lexicon-perl \
libmojolicious-perl \
libtest2-suite-perl \
Expand Down
6 changes: 3 additions & 3 deletions lib/AnswerHash.pm
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ The answer hash class is guaranteed to contain the following instance variables:

package AnswerHash;
use Exporter;
use PGUtil qw(not_null pretty_print);
use JSON;
use PGUtil qw(not_null pretty_print);
use Mojo::JSON qw(encode_json);

# initialization fields
my %fields = (
Expand Down Expand Up @@ -269,7 +269,7 @@ sub stringify_hash {
my $ref = ref($self->{$key});
next if !$ref;
if ($ref eq "HASH" or $ref eq "ARRAY") {
$self->{$key} = JSON->new->utf8->allow_unknown->convert_blessed->allow_blessed->encode($self->{$key});
$self->{$key} = encode_json($self->{$key});
} else {
$self->{$key} = "$self->{$key}";
}
Expand Down
6 changes: 3 additions & 3 deletions lib/DragNDrop.pm
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ package DragNDrop;
use strict;
use warnings;

use JSON;
use Mojo::JSON qw(encode_json);

use PGcore;

Expand Down Expand Up @@ -154,8 +154,8 @@ sub HTML {
my $self = shift;

my $out = qq{<div class="dd-bucket-pool" data-answer-name="$self->{answerName}"};
$out .= ' data-item-list="' . PGcore::encode_pg_and_html(JSON->new->encode($self->{itemList})) . '"';
$out .= ' data-default-state="' . PGcore::encode_pg_and_html(JSON->new->encode($self->{defaultBuckets})) . '"';
$out .= ' data-item-list="' . PGcore::encode_pg_and_html(encode_json($self->{itemList})) . '"';
$out .= ' data-default-state="' . PGcore::encode_pg_and_html(encode_json($self->{defaultBuckets})) . '"';
$out .= qq{ data-remove-button-text="$self->{removeButtonText}"};
$out .= qq{ data-label-format="$self->{bucketLabelFormat}"} if $self->{bucketLabelFormat};
$out .= '>';
Expand Down
2 changes: 1 addition & 1 deletion lib/Value.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ sub string {
return $open . join($comma, @coords) . $close;
}

# This is called by JSON->encode when convert_blessed is true to convert this value object into a string.
# This is called by Mojo::JSON::encode_json when convert_blessed is true to convert this value object into a string.
sub TO_JSON {
return shift->string;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/WeBWorK/PG/IO.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use warnings;
use utf8;

use Encode qw(encode decode);
use JSON qw(decode_json);
use Mojo::JSON qw(decode_json);
use File::Spec::Functions qw(canonpath);
use File::Find qw(finddepth);

Expand Down
4 changes: 2 additions & 2 deletions macros/PG.pl
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ sub ENDDOCUMENT {
id => $name,
value => $inputs_ref->{$name} // '',
scalar(keys %$mq_part_opts)
? (data => { mq_opts => JSON->new->encode($mq_part_opts) })
? (data => { mq_opts => Mojo::JSON::encode_json($mq_part_opts) })
: ''
)->to_string
);
Expand Down Expand Up @@ -1257,7 +1257,7 @@ sub ENDDOCUMENT {
}
)->to_string
),
answer_labels => JSON->new->encode($response_obj->{response_order}),
answer_labels => Mojo::JSON::encode_json($response_obj->{response_order}),
bs_toggle => 'popover',
bs_trigger => 'click',
bs_placement => $showCorrectOnly ? 'right' : 'bottom',
Expand Down
2 changes: 1 addition & 1 deletion macros/graph/LiveGraphics3D.pl
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ sub LiveGraphics3D {
'div',
class => 'live-graphics-3d-container',
style => "width:${w}px;height:${h}px;border:1px solid black;",
data_options => JSON->new->encode({
data_options => Mojo::JSON::encode_json({
width => $w - 2,
height => $h - 2,
maxTicks => $options{max_ticks},
Expand Down
4 changes: 2 additions & 2 deletions macros/graph/parserGraphTool.pl
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ =head1 OPTIONS
For example the following value for C<JSXGraphOptions> will give the same result for the
JavaScript graph as the default values for the options above:

JSXGraphOptions => JSON->new->encode({
JSXGraphOptions => Mojo::JSON::encode_json({
boundingBox => [-10, 10, 10, -10],
defaultAxes => {
x => { ticks => { ticksDistance => 2, minorTicks => 1} },
Expand Down Expand Up @@ -2300,7 +2300,7 @@ sub ANS_NAME {
sub constructJSXGraphOptions {
my $self = shift;
return if defined($self->{JSXGraphOptions});
$self->{JSXGraphOptions} = JSON->new->encode({
$self->{JSXGraphOptions} = Mojo::JSON::encode_json({
boundingBox => $self->{bBox},
$self->{numberLine}
? (
Expand Down
4 changes: 2 additions & 2 deletions macros/parsers/parserRadioMultiAnswer.pl
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ sub cmp {
$options->{insertElement} = $selected->first->parent;
my $contents = $selected->first->parent->at('div.radio-content[data-radio]');
if ($contents) {
my $partNames = JSON->new->decode($contents->attr('data-part-names'));
my $partNames = Mojo::JSON::decode_json($contents->attr('data-part-names'));
for (@$partNames) {
my $ansRules = $contents->find(qq{[name="$_"]});
if (@$ansRules > 1) {
Expand Down Expand Up @@ -679,7 +679,7 @@ sub ans_rule {
class => 'radio-content',
data_radio => $radio_name,
data_index => $self->{values}[$i],
data_part_names => JSON->new->encode(\@part_names),
data_part_names => Mojo::JSON::encode_json(\@part_names),
sprintf($data[$i][0] =~ s/%s\*/%s/gr, @part_rules)
),
PTX => sprintf($data[$i][0] =~ s/%s\*/%s/gr, @part_rules)
Expand Down