aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--amalgamate/crow_all.h2
-rw-r--r--include/json.h2
-rw-r--r--tests/unittest.cpp4
3 files changed, 6 insertions, 2 deletions
diff --git a/amalgamate/crow_all.h b/amalgamate/crow_all.h
index ed5ee0d..72f0ece 100644
--- a/amalgamate/crow_all.h
+++ b/amalgamate/crow_all.h
@@ -1568,7 +1568,7 @@ namespace crow
}
template <typename T>
- wvalue& operator[](const std::vector<T>& v)
+ wvalue& operator=(const std::vector<T>& v)
{
if (t_ != type::List)
reset();
diff --git a/include/json.h b/include/json.h
index 0d5d41e..2ade280 100644
--- a/include/json.h
+++ b/include/json.h
@@ -1224,7 +1224,7 @@ namespace crow
}
template <typename T>
- wvalue& operator[](const std::vector<T>& v)
+ wvalue& operator=(const std::vector<T>& v)
{
if (t_ != type::List)
reset();
diff --git a/tests/unittest.cpp b/tests/unittest.cpp
index 57a4324..3a48f20 100644
--- a/tests/unittest.cpp
+++ b/tests/unittest.cpp
@@ -539,6 +539,10 @@ TEST(json_write)
y["scores"]["a"]["b"]["c"] = nullptr;
ASSERT_EQUAL(R"({"scores":{"a":{"b":{"c":null}}}})", json::dump(y));
+
+ y["scores"] = std::vector<int>{1,2,3};
+ ASSERT_EQUAL(R"({"scores":[1,2,3]})", json::dump(y));
+
}
TEST(template_basic)