diff --git a/include/ArduinoJson/ForwardDeclarations.hpp b/include/ArduinoJson/ForwardDeclarations.hpp index fc9a188e..a3ebf3a5 100644 --- a/include/ArduinoJson/ForwardDeclarations.hpp +++ b/include/ArduinoJson/ForwardDeclarations.hpp @@ -6,8 +6,6 @@ #pragma once -// TODO: cleanup - namespace ArduinoJson { class JsonArray; class JsonArrayConstIterator; diff --git a/include/ArduinoJson/Internals/CompactJsonWriter.hpp b/include/ArduinoJson/Internals/CompactJsonWriter.hpp index edd1e15b..abc39027 100644 --- a/include/ArduinoJson/Internals/CompactJsonWriter.hpp +++ b/include/ArduinoJson/Internals/CompactJsonWriter.hpp @@ -10,6 +10,7 @@ namespace ArduinoJson { namespace Internals { + class CompactJsonWriter : public JsonWriter { public: explicit CompactJsonWriter(Print *sink) : JsonWriter(sink) {} diff --git a/include/ArduinoJson/Internals/JsonArrayNode.hpp b/include/ArduinoJson/Internals/JsonArrayNode.hpp index 842bb443..13c3a62e 100644 --- a/include/ArduinoJson/Internals/JsonArrayNode.hpp +++ b/include/ArduinoJson/Internals/JsonArrayNode.hpp @@ -14,16 +14,10 @@ namespace Internals { class JsonArrayNode { public: - static JsonArrayNode* createFrom(JsonBuffer* buffer) { - void* ptr = buffer->alloc(sizeof(JsonArrayNode)); - return ptr ? new (ptr) JsonArrayNode() : NULL; - } + JsonArrayNode() : next(0) {} JsonArrayNode* next; JsonValue value; - - private: - JsonArrayNode() : next(0) {} }; } } diff --git a/include/ArduinoJson/Internals/JsonObjectNode.hpp b/include/ArduinoJson/Internals/JsonObjectNode.hpp index e3be8178..6ea76f7d 100644 --- a/include/ArduinoJson/Internals/JsonObjectNode.hpp +++ b/include/ArduinoJson/Internals/JsonObjectNode.hpp @@ -14,16 +14,10 @@ namespace Internals { class JsonObjectNode { public: - static JsonObjectNode* createFrom(JsonBuffer* buffer, const char* key) { - void* ptr = buffer->alloc(sizeof(JsonObjectNode)); - return ptr ? new (ptr) JsonObjectNode(key) : NULL; - } + JsonObjectNode(const char* k) : pair(k), next(NULL) {} JsonPair pair; JsonObjectNode* next; - - private: - JsonObjectNode(const char* k) : pair(k), next(NULL) {} }; } } diff --git a/include/ArduinoJson/Internals/JsonSerializer.hpp b/include/ArduinoJson/Internals/JsonSerializer.hpp index 2b815904..bba785cd 100644 --- a/include/ArduinoJson/Internals/JsonSerializer.hpp +++ b/include/ArduinoJson/Internals/JsonSerializer.hpp @@ -23,4 +23,4 @@ class JsonSerializer { JsonWriter &_writer; }; } -} \ No newline at end of file +} diff --git a/include/ArduinoJson/Internals/JsonWriter.hpp b/include/ArduinoJson/Internals/JsonWriter.hpp index 906e0fb7..aa25fab9 100644 --- a/include/ArduinoJson/Internals/JsonWriter.hpp +++ b/include/ArduinoJson/Internals/JsonWriter.hpp @@ -10,6 +10,7 @@ namespace ArduinoJson { namespace Internals { + class JsonWriter { public: explicit JsonWriter(Print *sink) : _sink(sink), _length(0) {} diff --git a/include/ArduinoJson/Internals/PrettyJsonWriter.hpp b/include/ArduinoJson/Internals/PrettyJsonWriter.hpp index 7975c641..ec2ea27a 100644 --- a/include/ArduinoJson/Internals/PrettyJsonWriter.hpp +++ b/include/ArduinoJson/Internals/PrettyJsonWriter.hpp @@ -11,6 +11,7 @@ namespace ArduinoJson { namespace Internals { + class PrettyJsonWriter : public JsonWriter { public: explicit PrettyJsonWriter(IndentedPrint *sink) diff --git a/include/ArduinoJson/Internals/QuotedString.hpp b/include/ArduinoJson/Internals/QuotedString.hpp index f144c658..311ed195 100644 --- a/include/ArduinoJson/Internals/QuotedString.hpp +++ b/include/ArduinoJson/Internals/QuotedString.hpp @@ -10,10 +10,10 @@ namespace ArduinoJson { namespace Internals { + class QuotedString { public: static size_t printTo(const char *, Print *); - static char *extractFrom(char *input, char **end); }; } diff --git a/include/ArduinoJson/JsonArray.hpp b/include/ArduinoJson/JsonArray.hpp index 0d944ef6..ec371abc 100644 --- a/include/ArduinoJson/JsonArray.hpp +++ b/include/ArduinoJson/JsonArray.hpp @@ -13,6 +13,7 @@ #include "JsonObject.hpp" namespace ArduinoJson { + class JsonArray : public JsonPrintable { friend class JsonBuffer; @@ -25,14 +26,15 @@ class JsonArray : public JsonPrintable { bool success() { return _buffer != NULL; } - value_type &operator[](int index) const; - value_type &add(); + value_type &operator[](int index) const { return at(index); } + value_type &at(int index) const; template void add(T value) { add().set(value); } + value_type &add(); void add(double value, int decimals) { add().set(value, decimals); } void add(JsonArray &nestedArray) { add().set(nestedArray); } void add(JsonObject &nestedObject) { add().set(nestedObject); } @@ -54,14 +56,21 @@ class JsonArray : public JsonPrintable { // constructor is private: instance must be created via a JsonBuffer JsonArray(JsonBuffer *buffer) : _buffer(buffer), _firstNode(NULL) {} - JsonArray(const JsonArray &); // copy is forbidden, use a reference instead - JsonArray &operator=( - const JsonArray &); // copy is forbidden, use a reference instead + // copy is forbidden, use a reference instead + JsonArray(const JsonArray &); + JsonArray &operator=(const JsonArray &); + Internals::JsonArrayNode *createNode(); inline void addNode(Internals::JsonArrayNode *node); JsonBuffer *_buffer; Internals::JsonArrayNode *_firstNode; static JsonArray _invalid; }; + +bool operator==(const JsonArray &left, const JsonArray &right) { + // two JsonArray are equal if they are the same instance + // (we don't compare the content) + return &left == &right; +} } diff --git a/include/ArduinoJson/JsonArrayConstIterator.hpp b/include/ArduinoJson/JsonArrayConstIterator.hpp index 4703987c..863bc83e 100644 --- a/include/ArduinoJson/JsonArrayConstIterator.hpp +++ b/include/ArduinoJson/JsonArrayConstIterator.hpp @@ -34,4 +34,4 @@ class JsonArrayConstIterator { private: Internals::JsonArrayNode *_node; }; -} \ No newline at end of file +} diff --git a/include/ArduinoJson/JsonBuffer.hpp b/include/ArduinoJson/JsonBuffer.hpp index ca323c37..b16a321d 100644 --- a/include/ArduinoJson/JsonBuffer.hpp +++ b/include/ArduinoJson/JsonBuffer.hpp @@ -6,8 +6,6 @@ #pragma once -#include - #include "ForwardDeclarations.hpp" #include "JsonValue.hpp" diff --git a/include/ArduinoJson/JsonObject.hpp b/include/ArduinoJson/JsonObject.hpp index cff469e3..52e39ca3 100644 --- a/include/ArduinoJson/JsonObject.hpp +++ b/include/ArduinoJson/JsonObject.hpp @@ -13,6 +13,7 @@ #include "JsonArray.hpp" namespace ArduinoJson { + class JsonObject : public JsonPrintable { friend class JsonBuffer; @@ -22,16 +23,18 @@ class JsonObject : public JsonPrintable { typedef JsonObjectIterator iterator; typedef JsonObjectConstIterator const_iterator; + bool success() const { return _buffer != NULL; } int size() const; - JsonValue &operator[](key_type key); + JsonValue &at(key_type key); + JsonValue &operator[](key_type key) { return at(key); } + void remove(key_type key); template void add(key_type key, T value) { add(key).set(value); } - void add(key_type key, JsonArray &array) { add(key).set(array); } void add(key_type key, JsonObject &object) { add(key).set(object); } @@ -57,6 +60,7 @@ class JsonObject : public JsonPrintable { const JsonObject &); // copy is forbidden, use a reference instead JsonValue &add(key_type key) { return (*this)[key]; } + Internals::JsonObjectNode *createNode(key_type key); void addNode(Internals::JsonObjectNode *nodeToAdd); void removeNode(Internals::JsonObjectNode *nodeToRemove); @@ -67,4 +71,10 @@ class JsonObject : public JsonPrintable { Internals::JsonObjectNode *_firstNode; static JsonObject _invalid; }; + +bool operator==(const JsonObject &left, const JsonObject &right) { + // two JsonObject are equal if they are the same instance + // (we don't compare the content) + return &left == &right; +} } diff --git a/include/ArduinoJson/JsonPair.hpp b/include/ArduinoJson/JsonPair.hpp index 774fb84a..d540ad30 100644 --- a/include/ArduinoJson/JsonPair.hpp +++ b/include/ArduinoJson/JsonPair.hpp @@ -10,6 +10,7 @@ #include "Internals/JsonObjectNode.hpp" namespace ArduinoJson { + struct JsonPair { JsonPair(const char* k) : key(k) {} diff --git a/include/ArduinoJson/JsonValue.hpp b/include/ArduinoJson/JsonValue.hpp index df90a9be..594c48ce 100644 --- a/include/ArduinoJson/JsonValue.hpp +++ b/include/ArduinoJson/JsonValue.hpp @@ -13,7 +13,6 @@ #include "Internals/JsonValueType.hpp" namespace ArduinoJson { - class JsonValue { public: JsonValue() : _type(Internals::JSON_UNDEFINED) {} @@ -64,7 +63,10 @@ class JsonValue { void writeTo(Internals::JsonWriter &writer) const; private: + JsonValue(Internals::JsonValueType type) : _type(type) {} + Internals::JsonValueType _type; Internals::JsonValueContent _content; static JsonValue _invalid; }; +} diff --git a/src/JsonArray.cpp b/src/JsonArray.cpp index 72972e30..0233df70 100644 --- a/src/JsonArray.cpp +++ b/src/JsonArray.cpp @@ -6,6 +6,8 @@ #include "ArduinoJson/JsonArray.hpp" +#include // required for placement new + #include "ArduinoJson/JsonBuffer.hpp" #include "ArduinoJson/JsonObject.hpp" #include "ArduinoJson/Internals/JsonWriter.hpp" @@ -13,20 +15,22 @@ using namespace ArduinoJson; using namespace ArduinoJson::Internals; +JsonArray JsonArray::_invalid(NULL); + int JsonArray::size() const { int nodeCount = 0; for (JsonArrayNode *node = _firstNode; node; node = node->next) nodeCount++; return nodeCount; } -JsonValue &JsonArray::operator[](int index) const { +JsonValue &JsonArray::at(int index) const { JsonArrayNode *node = _firstNode; while (node && index--) node = node->next; return node ? node->value : JsonValue::invalid(); } JsonValue &JsonArray::add() { - JsonArrayNode *node = JsonArrayNode::createFrom(_buffer); + JsonArrayNode *node = createNode(); if (!node) return JsonValue::invalid(); addNode(node); @@ -34,6 +38,12 @@ JsonValue &JsonArray::add() { return node->value; } +JsonArrayNode *JsonArray::createNode() { + if (_buffer) return NULL; + void *ptr = _buffer->alloc(sizeof(JsonArrayNode)); + return ptr ? new (ptr) JsonArrayNode() : NULL; +} + void JsonArray::addNode(JsonArrayNode *newNode) { if (_firstNode) { JsonArrayNode *lastNode = _firstNode; diff --git a/src/JsonBuffer.cpp b/src/JsonBuffer.cpp index fa59ce20..c09a8f96 100644 --- a/src/JsonBuffer.cpp +++ b/src/JsonBuffer.cpp @@ -6,6 +6,8 @@ #include "ArduinoJson/JsonBuffer.hpp" +#include // required for the placement new + #include "ArduinoJson/JsonArray.hpp" #include "ArduinoJson/JsonObject.hpp" #include "ArduinoJson/JsonValue.hpp" diff --git a/src/JsonObject.cpp b/src/JsonObject.cpp index 277920fe..27438d31 100644 --- a/src/JsonObject.cpp +++ b/src/JsonObject.cpp @@ -6,6 +6,7 @@ #include "ArduinoJson/JsonObject.hpp" +#include // required for placement new #include // for strcmp #include "ArduinoJson/JsonBuffer.hpp" @@ -17,13 +18,15 @@ using namespace ArduinoJson; using namespace ArduinoJson::Internals; +JsonObject JsonObject::_invalid(NULL); + int JsonObject::size() const { int nodeCount = 0; for (JsonObjectNode *node = _firstNode; node; node = node->next) nodeCount++; return nodeCount; } -JsonValue &JsonObject::operator[](const char *key) { +JsonValue &JsonObject::at(const char *key) { JsonObjectNode *node = getOrCreateNodeAt(key); return node ? node->pair.value : JsonValue::invalid(); } @@ -55,13 +58,19 @@ JsonObjectNode *JsonObject::getOrCreateNodeAt(const char *key) { JsonObjectNode *existingNode = getNodeAt(key); if (existingNode) return existingNode; - JsonObjectNode *newNode = JsonObjectNode::createFrom(_buffer, key); + JsonObjectNode *newNode = createNode(key); if (newNode) addNode(newNode); return newNode; } +JsonObjectNode *JsonObject::createNode(const char *key) { + if (!_buffer) return NULL; + void *ptr = _buffer->alloc(sizeof(JsonObjectNode)); + return ptr ? new (ptr) JsonObjectNode(key) : NULL; +} + void JsonObject::addNode(JsonObjectNode *nodeToAdd) { if (!_firstNode) { _firstNode = nodeToAdd; diff --git a/src/JsonValue.cpp b/src/JsonValue.cpp index 06cb26b9..c0bdfc1a 100644 --- a/src/JsonValue.cpp +++ b/src/JsonValue.cpp @@ -12,6 +12,8 @@ using namespace ArduinoJson; using namespace ArduinoJson::Internals; +JsonValue JsonValue::_invalid(JSON_INVALID); + JsonValue::operator JsonArray &() const { return _type == JSON_ARRAY ? *_content.asArray : JsonArray::invalid(); } diff --git a/test/JsonObject_PrettyPrintTo_Tests.cpp b/test/JsonObject_PrettyPrintTo_Tests.cpp index d356f36c..0ed70055 100644 --- a/test/JsonObject_PrettyPrintTo_Tests.cpp +++ b/test/JsonObject_PrettyPrintTo_Tests.cpp @@ -13,11 +13,12 @@ using namespace ArduinoJson; class JsonObject_PrettyPrintTo_Tests : public testing::Test { - protected: - JsonObject object; - StaticJsonBuffer<30> json; + public: + JsonObject_PrettyPrintTo_Tests() : object(json.createObject()) {} - virtual void SetUp() { object = json.createObject(); } + protected: + JsonObject &object; + StaticJsonBuffer<30> json; void outputMustBe(const char *expected) { size_t n = object.prettyPrintTo(buffer, sizeof(buffer)); @@ -63,10 +64,10 @@ TEST_F(JsonObject_PrettyPrintTo_Tests, EmptyNestedContainers) { } TEST_F(JsonObject_PrettyPrintTo_Tests, NestedContainers) { - JsonObject nested1 = object.createNestedObject("key1"); + JsonObject &nested1 = object.createNestedObject("key1"); nested1["a"] = 1; - JsonArray nested2 = object.createNestedArray("key2"); + JsonArray &nested2 = object.createNestedArray("key2"); nested2.add(2); outputMustBe( diff --git a/test/JsonObject_Serialization_Tests.cpp b/test/JsonObject_Serialization_Tests.cpp index 1ea4b0d9..ee415221 100644 --- a/test/JsonObject_Serialization_Tests.cpp +++ b/test/JsonObject_Serialization_Tests.cpp @@ -13,9 +13,10 @@ using namespace ArduinoJson; class JsonObject_Serialization_Tests : public testing::Test { - protected: - virtual void SetUp() { object = json.createObject(); } + public: + JsonObject_Serialization_Tests() : object(json.createObject()) {} + protected: void outputMustBe(const char *expected) { char actual[256]; int result = object.printTo(actual, sizeof(actual)); @@ -24,7 +25,7 @@ class JsonObject_Serialization_Tests : public testing::Test { EXPECT_EQ(strlen(expected), result); } - JsonObject object; + JsonObject &object; StaticJsonBuffer<5> json; }; @@ -113,7 +114,7 @@ TEST_F(JsonObject_Serialization_Tests, OneFalse) { } TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArrayViaProxy) { - JsonArray nestedArray = json.createArray(); + JsonArray &nestedArray = json.createArray(); object["key"] = nestedArray; @@ -121,7 +122,7 @@ TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedArrayViaProxy) { } TEST_F(JsonObject_Serialization_Tests, OneEmptyNestedObjectViaProxy) { - JsonObject nestedArray = json.createObject(); + JsonObject &nestedArray = json.createObject(); object["key"] = nestedArray; diff --git a/test/JsonParser_Array_Tests.cpp b/test/JsonParser_Array_Tests.cpp index c5891211..6b1b33a1 100644 --- a/test/JsonParser_Array_Tests.cpp +++ b/test/JsonParser_Array_Tests.cpp @@ -15,17 +15,17 @@ class JsonParser_Array_Tests : public testing::Test { protected: void whenInputIs(const char *json) { strcpy(_jsonString, json); - _array = _jsonBuffer.parseArray(_jsonString); + _array = &_jsonBuffer.parseArray(_jsonString); } - void parseMustSucceed() { EXPECT_TRUE(_array.success()); } + void parseMustSucceed() { EXPECT_TRUE(_array->success()); } void parseMustFail() { - EXPECT_FALSE(_array.success()); - EXPECT_EQ(0, _array.size()); + EXPECT_FALSE(_array->success()); + EXPECT_EQ(0, _array->size()); } - void sizeMustBe(int expected) { EXPECT_EQ(expected, _array.size()); } + void sizeMustBe(int expected) { EXPECT_EQ(expected, _array->size()); } template void firstElementMustBe(T expected) { @@ -39,15 +39,15 @@ class JsonParser_Array_Tests : public testing::Test { template void elementAtIndexMustBe(int index, T expected) { - EXPECT_EQ(expected, _array[index].as()); + EXPECT_EQ(expected, _array->at(index).as()); } void elementAtIndexMustBe(int index, const char *expected) { - EXPECT_STREQ(expected, _array[index].as()); + EXPECT_STREQ(expected, _array->at(index).as()); } StaticJsonBuffer<42> _jsonBuffer; - JsonArray _array; + JsonArray *_array; char _jsonString[256]; }; diff --git a/test/JsonParser_Nested_Tests.cpp b/test/JsonParser_Nested_Tests.cpp index cb5c8ca0..4d350448 100644 --- a/test/JsonParser_Nested_Tests.cpp +++ b/test/JsonParser_Nested_Tests.cpp @@ -15,9 +15,9 @@ TEST(JsonParser_Nested_Tests, ArrayNestedInObject) { StaticJsonBuffer<42> jsonBuffer; char jsonString[] = " { \"ab\" : [ 1 , 2 ] , \"cd\" : [ 3 , 4 ] } "; - JsonObject object = jsonBuffer.parseObject(jsonString); - JsonArray array1 = object["ab"]; - JsonArray array2 = object["cd"]; + JsonObject &object = jsonBuffer.parseObject(jsonString); + JsonArray &array1 = object["ab"]; + JsonArray &array2 = object["cd"]; ASSERT_TRUE(object.success()); @@ -39,9 +39,9 @@ TEST(JsonParser_Nested_Tests, ObjectNestedInArray) { char jsonString[] = " [ { \"a\" : 1 , \"b\" : 2 } , { \"c\" : 3 , \"d\" : 4 } ] "; - JsonArray array = jsonBuffer.parseArray(jsonString); - JsonObject object1 = array[0]; - JsonObject object2 = array[1]; + JsonArray &array = jsonBuffer.parseArray(jsonString); + JsonObject &object1 = array[0]; + JsonObject &object2 = array[1]; ASSERT_TRUE(array.success()); diff --git a/test/JsonParser_Object_Tests.cpp b/test/JsonParser_Object_Tests.cpp index 6f3ad588..fd8d3607 100644 --- a/test/JsonParser_Object_Tests.cpp +++ b/test/JsonParser_Object_Tests.cpp @@ -15,27 +15,27 @@ class JsonParser_Object_Test : public testing::Test { protected: void whenInputIs(const char *jsonString) { strcpy(_jsonString, jsonString); - _object = _jsonBuffer.parseObject(_jsonString); + _object = &_jsonBuffer.parseObject(_jsonString); } - void parseMustSucceed() { EXPECT_TRUE(_object.success()); } + void parseMustSucceed() { EXPECT_TRUE(_object->success()); } - void parseMustFail() { EXPECT_FALSE(_object.success()); } + void parseMustFail() { EXPECT_FALSE(_object->success()); } - void sizeMustBe(int expected) { EXPECT_EQ(expected, _object.size()); } + void sizeMustBe(int expected) { EXPECT_EQ(expected, _object->size()); } void keyMustHaveValue(const char *key, const char *expected) { - EXPECT_STREQ(expected, _object[key].as()); + EXPECT_STREQ(expected, _object->at(key).as()); } template void keyMustHaveValue(const char *key, T expected) { - EXPECT_EQ(expected, _object[key].as()); + EXPECT_EQ(expected, _object->at(key).as()); } private: StaticJsonBuffer<10> _jsonBuffer; - JsonObject _object; + JsonObject *_object; char _jsonString[256]; }; diff --git a/test/JsonValueTests.cpp b/test/JsonValueTests.cpp index 78c46875..6b0c754e 100644 --- a/test/JsonValueTests.cpp +++ b/test/JsonValueTests.cpp @@ -15,11 +15,6 @@ using namespace ArduinoJson; class JsonValueTests : public ::testing::Test { protected: - virtual void SetUp() { - jsonValue1 = json.createValue(); - jsonValue2 = json.createValue(); - } - StaticJsonBuffer<42> json; JsonValue jsonValue1; JsonValue jsonValue2; @@ -54,11 +49,11 @@ TEST_F(JsonValueTests, CanStoreString) { } TEST_F(JsonValueTests, CanStoreObject) { - JsonObject innerObject1 = json.createObject(); + JsonObject &innerObject1 = json.createObject(); jsonValue1 = innerObject1; - EXPECT_EQ(innerObject1, jsonValue1.as()); + EXPECT_EQ(innerObject1, jsonValue1.asObject()); } TEST_F(JsonValueTests, IntegersAreCopiedByValue) { @@ -94,21 +89,21 @@ TEST_F(JsonValueTests, StringsAreCopiedByValue) { } TEST_F(JsonValueTests, ObjectsAreCopiedByReference) { - JsonObject object = json.createObject(); + JsonObject &object = json.createObject(); jsonValue1 = object; object["hello"] = "world"; - EXPECT_EQ(1, jsonValue1.as().size()); + EXPECT_EQ(1, jsonValue1.asObject().size()); } TEST_F(JsonValueTests, ArraysAreCopiedByReference) { - JsonArray array = json.createArray(); + JsonArray &array = json.createArray(); jsonValue1 = array; array.add("world"); - EXPECT_EQ(1, jsonValue1.as().size()); + EXPECT_EQ(1, jsonValue1.asArray().size()); } diff --git a/test/StaticJsonBufferTests.cpp b/test/StaticJsonBufferTests.cpp index b3d92271..b3260a41 100644 --- a/test/StaticJsonBufferTests.cpp +++ b/test/StaticJsonBufferTests.cpp @@ -46,14 +46,14 @@ TEST(StaticJsonBuffer, WhenCreateObjectIsCalled_ThenAnEmptyJsonObjectIsReturned) { StaticJsonBuffer<42> json; - JsonObject obj = json.createObject(); + JsonObject &obj = json.createObject(); EXPECT_EQ(0, obj.size()); } TEST(StaticJsonBuffer, GivenAJsonObject_WhenValuesAreAdded_ThenSizeIsIncreasedByTwo) { StaticJsonBuffer<42> json; - JsonObject obj = json.createObject(); + JsonObject &obj = json.createObject(); obj["hello"]; EXPECT_EQ(3, json.size()); @@ -66,7 +66,7 @@ TEST( StaticJsonBuffer, GivenAJsonObject_WhenSameValuesAreAddedTwice_ThenSizeIsOnlyIncreasedByTwo) { StaticJsonBuffer<42> json; - JsonObject obj = json.createObject(); + JsonObject &obj = json.createObject(); obj["hello"]; EXPECT_EQ(3, json.size());