فهرست منبع

Serialize booleans in objects

Benoit Blanchon 11 سال پیش
والد
کامیت
065fe57a7c
2فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 4 0
      srcs/JsonObject.cpp
  2. 2 2
      tests/JsonObjectSerializationTests.cpp

+ 4 - 0
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)

+ 2 - 2
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>();