diff options
author | ipknHama <ipknhama@gmail.com> | 2015-01-08 08:20:38 +0900 |
---|---|---|
committer | ipknHama <ipknhama@gmail.com> | 2015-01-08 08:22:06 +0900 |
commit | 3fc1424e6260c96f3ed255714ba29a56b6439299 (patch) | |
tree | 438590a8422004d24014a223653c952041f371e2 | |
parent | 345174564afb6ac44ac9eb11367e974c040965b4 (diff) | |
download | crow-3fc1424e6260c96f3ed255714ba29a56b6439299.tar.gz crow-3fc1424e6260c96f3ed255714ba29a56b6439299.zip |
fix issue #39, bug at assigning vector to json wvalue
-rw-r--r-- | amalgamate/crow_all.h | 2 | ||||
-rw-r--r-- | include/json.h | 2 | ||||
-rw-r--r-- | tests/unittest.cpp | 4 |
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) |