diff --git a/srcs/JsonNode.h b/srcs/JsonNode.h
index f8d585f9..4f9101fe 100644
--- a/srcs/JsonNode.h
+++ b/srcs/JsonNode.h
@@ -24,7 +24,7 @@ struct JsonNode
union
{
- // int asInteger;
+ int asInteger;
struct
{
diff --git a/srcs/JsonObject.cpp b/srcs/JsonObject.cpp
index 974adf21..7f31e38c 100644
--- a/srcs/JsonObject.cpp
+++ b/srcs/JsonObject.cpp
@@ -48,7 +48,7 @@ size_t JsonObject::size()
JsonValue JsonObject::operator[](char const* key)
{
JsonNode* node = getOrCreateNodeAt(key);
- return JsonValue(/*node*/);
+ return JsonValue(node);
}
JsonNode* JsonObject::getOrCreateNodeAt(char const* key)
diff --git a/srcs/JsonValue.cpp b/srcs/JsonValue.cpp
new file mode 100644
index 00000000..dcfbc9ce
--- /dev/null
+++ b/srcs/JsonValue.cpp
@@ -0,0 +1,28 @@
+#include "JsonObject.h"
+#include "JsonNode.h"
+#include "JsonValue.h"
+
+//void JsonValue::operator=(JsonObject const& object)
+//{
+// _node = object._node;
+//}
+
+void JsonValue::operator=(int value)
+{
+ if (!_node) return;
+
+ _node->type = JSON_INTEGER;
+ _node->content.asInteger = value;
+}
+
+//JsonValue::operator JsonObject()
+//{
+// return JsonObject(_buffer, _node);
+//}
+
+JsonValue::operator int()
+{
+ if (!_node || _node->type != JSON_INTEGER) return 0;
+
+ return _node->content.asInteger;
+}
\ No newline at end of file
diff --git a/srcs/JsonValue.h b/srcs/JsonValue.h
index cf3e9f85..692de4fd 100644
--- a/srcs/JsonValue.h
+++ b/srcs/JsonValue.h
@@ -6,21 +6,21 @@
class JsonValue
{
-//public:
-//
-// JsonValue(JsonBuffer& buffer, JsonNode& node)
-// : _buffer(buffer), _node(node)
-// {
-// }
-//
-// void operator=(const JsonObject& object);
-// void operator=(int);
-//
-// operator JsonObject();
-// operator int();
-//
-//private:
-// JsonBuffer& _buffer;
-// JsonNode& _node;
+public:
+
+ JsonValue(JsonNode* node)
+ : _node(node)
+ {
+ }
+
+ // void operator=(const JsonObject& object);
+ void operator=(int);
+
+ // operator JsonObject();
+ operator int();
+
+private:
+ //JsonBuffer& _buffer;
+ JsonNode* _node;
};
diff --git a/srcs/srcs.vcxproj b/srcs/srcs.vcxproj
index b679eaad..c6afde80 100644
--- a/srcs/srcs.vcxproj
+++ b/srcs/srcs.vcxproj
@@ -74,6 +74,7 @@
+
diff --git a/srcs/srcs.vcxproj.filters b/srcs/srcs.vcxproj.filters
index b13d846d..397cae34 100644
--- a/srcs/srcs.vcxproj.filters
+++ b/srcs/srcs.vcxproj.filters
@@ -38,5 +38,8 @@
Source Files
+
+ Source Files
+
\ No newline at end of file
diff --git a/tests/JsonObjectTests.cpp b/tests/JsonObjectTests.cpp
index 45175fdf..ca7e97d3 100644
--- a/tests/JsonObjectTests.cpp
+++ b/tests/JsonObjectTests.cpp
@@ -26,4 +26,17 @@ TEST(JsonObjectTests, WhenTheSameValueIsAddedTwice_ThenSizeIsOnlyIncreasedByOne)
object["hello"];
EXPECT_EQ(1, object.size());
+}
+
+TEST(JsonObjectTests, WhenAnIntegerIsStore_TheSameIntegerIsRetreived)
+{
+ StaticJsonBuffer<42> json;
+
+ JsonObject object = json.createObject();
+
+ object["hello"] = 123;
+ object["world"] = 456;
+
+ EXPECT_EQ(123, (int) object["hello"]);
+ EXPECT_EQ(456, (int) object["world"]);
}
\ No newline at end of file