@@ -19,17 +19,21 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
1919 PrettyJsonSerializer (TWriter writer, ResourceManager* resources)
2020 : base(writer, resources), nesting_(0 ) {}
2121
22- size_t visit (const ArrayImpl& array) {
23- auto it = array.createIterator ();
24- if (!it.done ()) {
22+ size_t visitArray (VariantData* array) {
23+ ARDUINOJSON_ASSERT (array != nullptr );
24+ ARDUINOJSON_ASSERT (array->isArray ());
25+
26+ auto slotId = array->content .asCollection .head ;
27+ if (slotId != NULL_SLOT) {
2528 base::write (" [\r\n " );
2629 nesting_++;
27- while (!it. done () ) {
30+ while (slotId != NULL_SLOT ) {
2831 indent ();
29- VariantImpl::accept (*this , it.data (), base::resources_);
32+ auto slot = base::resources_->getVariant (slotId);
33+ VariantImpl::accept (*this , slot, base::resources_);
3034
31- it. next (base::resources_) ;
32- base::write (it. done () ? " \r\n " : " ,\r\n " );
35+ slotId = slot-> next ;
36+ base::write (slotId == NULL_SLOT ? " \r\n " : " ,\r\n " );
3337 }
3438 nesting_--;
3539 indent ();
@@ -40,21 +44,25 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
4044 return this ->bytesWritten ();
4145 }
4246
43- size_t visit (const ObjectImpl& object) {
44- auto it = object.createIterator ();
45- if (!it.done ()) {
47+ size_t visitObject (VariantData* object) {
48+ ARDUINOJSON_ASSERT (object != nullptr );
49+ ARDUINOJSON_ASSERT (object->isObject ());
50+
51+ auto slotId = object->content .asCollection .head ;
52+ if (slotId != NULL_SLOT) {
4653 base::write (" {\r\n " );
4754 nesting_++;
4855 bool isKey = true ;
49- while (!it. done () ) {
56+ while (slotId != NULL_SLOT ) {
5057 if (isKey)
5158 indent ();
52- VariantImpl::accept (*this , it.data (), base::resources_);
53- it.next (base::resources_);
59+ auto slot = base::resources_->getVariant (slotId);
60+ VariantImpl::accept (*this , slot, base::resources_);
61+ slotId = slot->next ;
5462 if (isKey)
5563 base::write (" : " );
5664 else
57- base::write (it. done () ? " \r\n " : " ,\r\n " );
65+ base::write (slotId == NULL_SLOT ? " \r\n " : " ,\r\n " );
5866 isKey = !isKey;
5967 }
6068 nesting_--;
0 commit comments