aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/FixMyStreet/App/Controller/Around.pm
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2016-03-28 20:38:28 +0200
committerMarius Halden <marius.h@lden.org>2016-03-28 20:38:28 +0200
commit6c1118dbf2c4b15bcfcd77600d36f2389428c75e (patch)
treeda81756a344a89502df5479b860b6f4a24b6ed92 /perllib/FixMyStreet/App/Controller/Around.pm
parenta2d67ca6de255ff04badb7cb5a62f7d3df3ce293 (diff)
parent4345263c9de752454795ad57323e684e41e702a8 (diff)
Merge tag 'v1.8.1' into fiksgatami-dev
Diffstat (limited to 'perllib/FixMyStreet/App/Controller/Around.pm')
-rw-r--r--perllib/FixMyStreet/App/Controller/Around.pm13
1 files changed, 7 insertions, 6 deletions
diff --git a/perllib/FixMyStreet/App/Controller/Around.pm b/perllib/FixMyStreet/App/Controller/Around.pm
index 4aa695ae5..1e6d9ec9e 100644
--- a/perllib/FixMyStreet/App/Controller/Around.pm
+++ b/perllib/FixMyStreet/App/Controller/Around.pm
@@ -6,6 +6,7 @@ BEGIN { extends 'Catalyst::Controller'; }
use FixMyStreet::Map;
use Encode;
+use JSON::MaybeXS;
use Utils;
=head1 NAME
@@ -306,7 +307,7 @@ sub ajax : Path('/ajax') {
# JSON encode the response
my $json = { pins => $pins };
$json->{current} = $on_map_list_html if $on_map_list_html;
- my $body = JSON->new->utf8(1)->encode($json);
+ my $body = encode_json($json);
$c->res->body($body);
}
@@ -350,8 +351,10 @@ sub _geocode : Private {
} else {
if ( ref($suggestions) eq 'ARRAY' ) {
foreach (@$suggestions) {
- push @addresses, decode_utf8($_->{address});
- push @locations, { address => decode_utf8($_->{address}), lat => $_->{latitude}, long => $_->{longitude} };
+ my $address = $_->{address};
+ $address = decode_utf8($address) if !utf8::is_utf8($address);
+ push @addresses, $address;
+ push @locations, { address => $address, lat => $_->{latitude}, long => $_->{longitude} };
}
$response = { suggestions => \@addresses, locations => \@locations };
} else {
@@ -363,9 +366,7 @@ sub _geocode : Private {
$response = \@addresses;
}
- my $body = JSON->new->utf8(1)->encode(
- $response
- );
+ my $body = encode_json($response);
$c->res->body($body);
}