FlexBuffers: JSON output supports indentation

This commit is contained in:
Wouter van Oortmerssen
2023-06-14 17:57:00 -07:00
parent f8fe811d5c
commit 23922e7eba
2 changed files with 60 additions and 14 deletions

View File

@@ -132,6 +132,12 @@ void FlexBuffersTest() {
// And from FlexBuffer back to JSON:
auto jsonback = jroot.ToString();
TEST_EQ_STR(jsontest, jsonback.c_str());
// With indentation:
std::string jsonback_indented;
jroot.ToString(true, false, jsonback_indented, true, 0, " ");
auto jsontest_indented =
"{\n a: [\n 123,\n 456.0\n ],\n b: \"hello\",\n c: true,\n d: false\n}";
TEST_EQ_STR(jsontest_indented, jsonback_indented.c_str());
slb.Clear();
slb.Vector([&]() {