diff --git a/include/matjson3.hpp b/include/matjson3.hpp index 5702ae7..f2d251e 100644 --- a/include/matjson3.hpp +++ b/include/matjson3.hpp @@ -107,6 +107,11 @@ namespace matjson { Value(Value&&); ~Value(); + /// Create an empty JSON object + static Value object(); + /// Create an empty JSON array + static Value array(); + Value& operator=(Value); /// Parses JSON from a string diff --git a/src/value.cpp b/src/value.cpp index 54e6843..e11f1b3 100644 --- a/src/value.cpp +++ b/src/value.cpp @@ -61,6 +61,13 @@ Value::Value(Value&& other) { Value::~Value() {} +Value Value::object() { + return Value(std::make_unique(Type::Object, Array{})); +} +Value Value::array() { + return Value(std::make_unique(Type::Array, Array{})); +} + Value& Value::operator=(Value value) { if (CHECK_DUMMY_NULL) return *this; auto key = m_impl->key();