implemented an indentation character #520

An optional parameter for dump() allows to set the character to use for
indentation (default: space). In case a JSON value is serialized to an
output stream, its fill character is used (and can be set with
std::setfill).
This commit is contained in:
Niels Lohmann 2017-05-07 19:27:40 +02:00
parent fba1bcdd0b
commit 962da00171
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
10 changed files with 76 additions and 16 deletions

View file

@ -207,6 +207,12 @@ TEST_CASE("object inspection")
"{\n\"array\": [\n1,\n2,\n3,\n4\n],\n\"boolean\": false,\n\"null\": null,\n\"number\": 42,\n\"object\": {},\n\"string\": \"Hello world\"\n}");
}
SECTION("indent=1, space='\t'")
{
CHECK(j.dump(1, '\t') ==
"{\n\t\"array\": [\n\t\t1,\n\t\t2,\n\t\t3,\n\t\t4\n\t],\n\t\"boolean\": false,\n\t\"null\": null,\n\t\"number\": 42,\n\t\"object\": {},\n\t\"string\": \"Hello world\"\n}");
}
SECTION("indent=4")
{
CHECK(j.dump(4) ==