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