From 2ffd32031666f7270416b3cd8a1af72b3f1f4f82 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 27 Jul 2021 03:09:42 +0200 Subject: [PATCH] JSON::Iter::remove() now resets the internal state back to the beginning of the iteration on the root JSON::Value object. --- lib/json.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/json.cpp b/lib/json.cpp index e5b1d32e..cfbfc9df 100644 --- a/lib/json.cpp +++ b/lib/json.cpp @@ -66,15 +66,17 @@ uint32_t JSON::Iter::num() const{ } /// Delete the current indice from the parent JSON::Value. +/// Resets the iterator to restart from the beginning void JSON::Iter::remove(){ if (*this){ + i = 0; if (myType == JSON::ARRAY){ r->removeMember(aIt); - return; + aIt = r->arrVal.begin(); } if (myType == JSON::OBJECT){ r->removeMember(oIt); - return; + oIt = r->objVal.begin(); } } }