Skip to content

Commit

Permalink
add Value::object() and Value::array()
Browse files Browse the repository at this point in the history
  • Loading branch information
HJfod committed Nov 9, 2024
1 parent bfcef23 commit bbf4e46
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions include/matjson3.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions src/value.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ Value::Value(Value&& other) {

Value::~Value() {}

Value Value::object() {
return Value(std::make_unique<ValueImpl>(Type::Object, Array{}));
}
Value Value::array() {
return Value(std::make_unique<ValueImpl>(Type::Array, Array{}));
}

Value& Value::operator=(Value value) {
if (CHECK_DUMMY_NULL) return *this;
auto key = m_impl->key();
Expand Down

0 comments on commit bbf4e46

Please sign in to comment.