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);