From 3b64102f17c7aa15d2c346918030a162740def34 Mon Sep 17 00:00:00 2001 From: Daniel Nichter Date: Thu, 31 Jan 2013 17:48:25 -0700 Subject: [PATCH] Normalize newlines on end of JSON text, to handle whatever is wrong with JSON on CentOS 6. --- lib/Percona/WebAPI/Representation.pm | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Percona/WebAPI/Representation.pm b/lib/Percona/WebAPI/Representation.pm index 75ea6b7c..46b77f9c 100644 --- a/lib/Percona/WebAPI/Representation.pm +++ b/lib/Percona/WebAPI/Representation.pm @@ -53,9 +53,14 @@ sub as_json { $json->allow_blessed([]); $json->convert_blessed([]); - return $json->encode( + my $text = $json->encode( ref $resource eq 'ARRAY' ? $resource : as_hashref($resource, %args) ); + if ( $args{json} && $text ) { # for testing + chomp($text); + $text .= "\n"; + } + return $text; } sub as_config {