JsonEncode(): suffix pretty JSON w/ \n

refs #8194
This commit is contained in:
Alexander A. Klimov 2020-09-02 16:11:43 +02:00
parent 338d0aaa8c
commit 3adba5c542
2 changed files with 5 additions and 3 deletions

View File

@ -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<false> stateMachine;

View File

@ -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");