From 3adba5c542a7d06b317d9904b3c1530e35a6a8e1 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Wed, 2 Sep 2020 16:11:43 +0200 Subject: [PATCH] JsonEncode(): suffix pretty JSON w/ \n refs #8194 --- lib/base/json.cpp | 2 +- test/base-json.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/base/json.cpp b/lib/base/json.cpp index c1a47c788..d9e1718c2 100644 --- a/lib/base/json.cpp +++ b/lib/base/json.cpp @@ -193,7 +193,7 @@ String icinga::JsonEncode(const Value& value, bool pretty_print) Encode(stateMachine, value); - return stateMachine.GetResult(); + return stateMachine.GetResult() + "\n"; } else { JsonEncoder stateMachine; diff --git a/test/base-json.cpp b/test/base-json.cpp index 271d4f771..d97bd647c 100644 --- a/test/base-json.cpp +++ b/test/base-json.cpp @@ -36,7 +36,8 @@ BOOST_AUTO_TEST_CASE(encode) "string": "LF\nTAB\tAUml\u00e4Ill\ufffd", "true": true, "uint": 23.0 -})EOF"); +} +)EOF"); BOOST_CHECK(JsonEncode(input, true) == output); @@ -59,7 +60,8 @@ BOOST_AUTO_TEST_CASE(decode) "string": "LF\nTAB\tAUmlIll", "true": true, "uint": 23.0 -})EOF"); +} +)EOF"); boost::algorithm::replace_all(input, "AUml", "AUml\xC3\xA4"); boost::algorithm::replace_all(input, "Ill", "Ill\xC3");