From 065fe57a7c9fe5c35b68a7add06c4e1b5da1561e Mon Sep 17 00:00:00 2001 From: Benoit Blanchon Date: Tue, 30 Sep 2014 17:56:28 +0200 Subject: [PATCH] Serialize booleans in objects --- srcs/JsonObject.cpp | 4 ++++ tests/JsonObjectSerializationTests.cpp | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/srcs/JsonObject.cpp b/srcs/JsonObject.cpp index c1f359cd..2f00a7ef 100644 --- a/srcs/JsonObject.cpp +++ b/srcs/JsonObject.cpp @@ -122,6 +122,10 @@ size_t JsonObject::printTo(Print& p) const case JSON_INTEGER: n += p.print(childValue->content.asInteger); break; + + case JSON_BOOLEAN: + n += p.print(childValue->content.asBoolean ? "true" : "false"); + break; } if (childValue->type >= JSON_DOUBLE_0_DECIMALS) diff --git a/tests/JsonObjectSerializationTests.cpp b/tests/JsonObjectSerializationTests.cpp index 9b293aaf..07f7d89d 100644 --- a/tests/JsonObjectSerializationTests.cpp +++ b/tests/JsonObjectSerializationTests.cpp @@ -107,7 +107,7 @@ TEST_F(JsonObjectSerializationTests, OneDoubleDefaultDigits) object["key"] = 3.14159265358979323846; outputMustBe("{\"key\":3.14}"); } -/* + TEST_F(JsonObjectSerializationTests, OneNull) { object["key"] = (char*) 0; @@ -125,7 +125,7 @@ TEST_F(JsonObjectSerializationTests, OneFalse) object["key"] = false; outputMustBe("{\"key\":false}"); } - +/* TEST_F(JsonObjectSerializationTests, OneEmptyNestedArray) { auto nestedArray = JsonArray<1>();