diff options
author | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-12-10 21:24:57 +0000 |
---|---|---|
committer | Matthew Somerville <matthew@mysociety.org> | 2016-01-22 16:58:04 +0000 |
commit | 1c40be1f4b5a00fd6da081225b04efad228f8025 (patch) | |
tree | ec6e320f4d44c1a06deddfbd43050e2e04a6499b /perllib/FixMyStreet/App/Controller/Report/New.pm | |
parent | 61573768a8bd0a9f6c3ec69d405f153121e07563 (diff) |
Switch to JSON::MaybeXS, remove JSON::XS.
Travis has Cpanel::JSON::XS preinstalled, which means that the build
would fail there, as JSON::MaybeXS would try and upgrade JSON::XS to
version 3 which the snapshot did not contain.
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Report/New.pm')
-rw-r--r-- | perllib/FixMyStreet/App/Controller/Report/New.pm | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Report/New.pm b/perllib/FixMyStreet/App/Controller/Report/New.pm index db524ada4..1b4c1b295 100644 --- a/perllib/FixMyStreet/App/Controller/Report/New.pm +++ b/perllib/FixMyStreet/App/Controller/Report/New.pm @@ -12,7 +12,7 @@ use mySociety::MaPit; use Path::Class; use Utils; use mySociety::EmailUtil; -use JSON; +use JSON::MaybeXS; =head1 NAME @@ -164,9 +164,7 @@ sub report_new_ajax : Path('mobile') : Args(0) { sub send_json_response : Private { my ( $self, $c ) = @_; - my $body = JSON->new->utf8(1)->encode( - $c->stash->{json_response}, - ); + my $body = encode_json($c->stash->{json_response}); $c->res->content_type('application/json; charset=utf-8'); $c->res->body($body); } @@ -178,9 +176,7 @@ sub report_form_ajax : Path('ajax') : Args(0) { # work out the location for this report and do some checks if ( ! $c->forward('determine_location') ) { - my $body = JSON->new->utf8(1)->encode( { - error => $c->stash->{location_error}, - } ); + my $body = encode_json({ error => $c->stash->{location_error} }); $c->res->content_type('application/json; charset=utf-8'); $c->res->body($body); return; @@ -197,7 +193,7 @@ sub report_form_ajax : Path('ajax') : Args(0) { my $extra_titles_list = $c->cobrand->title_list($c->stash->{all_areas}); - my $body = JSON->new->utf8(1)->encode( + my $body = encode_json( { councils_text => $councils_text, category => $category, @@ -216,11 +212,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) { $c->forward('initialize_report'); if ( ! $c->forward('determine_location') ) { - my $body = JSON->new->utf8(1)->encode( - { - error => _("Sorry, we could not find that location."), - } - ); + my $body = encode_json({ error => _("Sorry, we could not find that location.") }); $c->res->content_type('application/json; charset=utf-8'); $c->res->body($body); return 1; @@ -244,11 +236,7 @@ sub category_extras_ajax : Path('category_extras') : Args(0) { $category_extra = $c->render_fragment( 'report/new/category_extras.html'); } - my $body = JSON->new->utf8(1)->encode( - { - category_extra => $category_extra, - } - ); + my $body = encode_json({ category_extra => $category_extra }); $c->res->content_type('application/json; charset=utf-8'); $c->res->body($body); |