From e1f7ee00b13ca71a2d2197b32dae73d8f703ba6c Mon Sep 17 00:00:00 2001 From: Dave Arter Date: Thu, 15 Mar 2018 10:57:31 +0000 Subject: Fix JSON-encoding crash on /report/ajax --- perllib/FixMyStreet/App/Controller/Report.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'perllib/FixMyStreet/App/Controller/Report.pm') diff --git a/perllib/FixMyStreet/App/Controller/Report.pm b/perllib/FixMyStreet/App/Controller/Report.pm index 7062f481f..df4dc5f77 100644 --- a/perllib/FixMyStreet/App/Controller/Report.pm +++ b/perllib/FixMyStreet/App/Controller/Report.pm @@ -221,9 +221,15 @@ sub format_problem_for_display : Private { if ( $c->stash->{ajax} ) { $c->res->content_type('application/json; charset=utf-8'); + + # encode_json doesn't like DateTime objects, so strip them out + my $report_hashref = $c->cobrand->problem_as_hashref( $problem, $c ); + delete $report_hashref->{created}; + delete $report_hashref->{confirmed}; + my $content = encode_json( { - report => $c->cobrand->problem_as_hashref( $problem, $c ), + report => $report_hashref, updates => $c->cobrand->updates_as_hashref( $problem, $c ), } ); -- cgit v1.2.3