From 617ee58b91c0148f52cd8985928bb33e0d136cb8 Mon Sep 17 00:00:00 2001 From: Martchus Date: Wed, 25 Oct 2017 16:37:49 +0200 Subject: [PATCH] Clear interatables before pulling array elements --- lib/jsonreflector.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/jsonreflector.h b/lib/jsonreflector.h index 37888ca..194a39b 100644 --- a/lib/jsonreflector.h +++ b/lib/jsonreflector.h @@ -202,6 +202,9 @@ template <> inline void pull(std::string &reflectable, const RAPIDJ template , Traits::Not>>...> void pull(Type &reflectable, rapidjson::GenericValue>::ValueIterator &value) { + // clear previous contents of the array (TODO: make this configurable) + reflectable.clear(); + // pull all array elements of the specified value for (const auto &item : value->GetArray()) { reflectable.emplace_back(); pull(reflectable.back(), item); @@ -212,6 +215,9 @@ void pull(Type &reflectable, rapidjson::GenericValue, Traits::Not>>...> void pull(Type &reflectable, const rapidjson::GenericValue> &value) { + // clear previous contents of the array (TODO: make this configurable) + reflectable.clear(); + // pull all array elements of the specified value for (const auto &item : value.GetArray()) { reflectable.emplace_back(); pull(reflectable.back(), item);