File tree Expand file tree Collapse file tree 1 file changed +16
-20
lines changed
Expand file tree Collapse file tree 1 file changed +16
-20
lines changed Original file line number Diff line number Diff line change @@ -22,17 +22,14 @@ class JsonSerializer : public VariantDataVisitor<size_t> {
2222 size_t visitArray (const VariantImpl& array) {
2323 write (' [' );
2424
25- auto slotId = array. head () ;
25+ bool first = true ;
2626
27- while (slotId != NULL_SLOT) {
28- auto slot = resources_->getVariant (slotId);
29-
30- VariantImpl (slot, resources_).accept (*this );
31-
32- slotId = slot->next ;
33-
34- if (slotId != NULL_SLOT)
27+ for (auto it = array.createIterator (); !it.done (); it.move ()) {
28+ if (!first)
3529 write (' ,' );
30+
31+ it->accept (*this );
32+ first = false ;
3633 }
3734
3835 write (' ]' );
@@ -42,20 +39,19 @@ class JsonSerializer : public VariantDataVisitor<size_t> {
4239 size_t visitObject (const VariantImpl& object) {
4340 write (' {' );
4441
45- auto slotId = object.head ();
42+ bool first = true ;
43+ bool isValue = false ;
4644
47- bool isKey = true ;
48-
49- while (slotId != NULL_SLOT) {
50- auto slot = resources_->getVariant (slotId);
51- VariantImpl (slot, resources_).accept (*this );
52-
53- slotId = slot->next ;
45+ for (auto it = object.createIterator (); !it.done (); it.move ()) {
46+ if (isValue)
47+ write (' :' );
48+ else if (!first)
49+ write (' ,' );
5450
55- if (slotId != NULL_SLOT)
56- write (isKey ? ' :' : ' ,' );
51+ it->accept (*this );
5752
58- isKey = !isKey;
53+ first = false ;
54+ isValue = !isValue;
5955 }
6056
6157 write (' }' );
You can’t perform that action at this time.
0 commit comments