From 410ca55e88fff6a9cc2319be80ef99da862cd938 Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Mon, 25 Aug 2014 10:34:28 +0200 Subject: [PATCH] Added a space before the object's values --- JsonGenerator/IndentedPrintDecorator.cpp | 11 +++++++++++ JsonGeneratorTests/IntentedPrintTests.cpp | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/JsonGenerator/IndentedPrintDecorator.cpp b/JsonGenerator/IndentedPrintDecorator.cpp index 56fed033..49bff98d 100644 --- a/JsonGenerator/IndentedPrintDecorator.cpp +++ b/JsonGenerator/IndentedPrintDecorator.cpp @@ -39,6 +39,17 @@ size_t IndentedPrintDecorator::write(uint8_t c) return sink.write(c) + writeln(); } + case ':': + previousChar = c; + if (isInAString) + { + return sink.write(c); + } + else + { + return sink.write(c) + sink.write(' '); + } + case '\"': if (previousChar != '\\') { diff --git a/JsonGeneratorTests/IntentedPrintTests.cpp b/JsonGeneratorTests/IntentedPrintTests.cpp index 78b94986..cfcf8458 100644 --- a/JsonGeneratorTests/IntentedPrintTests.cpp +++ b/JsonGeneratorTests/IntentedPrintTests.cpp @@ -42,7 +42,7 @@ namespace JsonGeneratorTests whenInputIs("{\"key\":\"value\"}"); outputMustBe( "{\n" - " \"key\":\"value\"\n" + " \"key\": \"value\"\n" "}"); } @@ -51,8 +51,8 @@ namespace JsonGeneratorTests whenInputIs("{\"key1\":\"value1\",\"key2\":\"value2\"}"); outputMustBe( "{\n" - " \"key1\":\"value1\",\n" - " \"key2\":\"value2\"\n" + " \"key1\": \"value1\",\n" + " \"key2\": \"value2\"\n" "}"); } @@ -61,7 +61,7 @@ namespace JsonGeneratorTests whenInputIs("{\"key\":\":\\\"',\"}"); outputMustBe( "{\n" - " \"key\":\":\\\"',\"\n" + " \"key\": \":\\\"',\"\n" "}"); }