|
|
@@ -19,17 +19,21 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
|
|
|
PrettyJsonSerializer(TWriter writer, ResourceManager* resources)
|
|
|
: base(writer, resources), nesting_(0) {}
|
|
|
|
|
|
- size_t visit(const ArrayImpl& array) {
|
|
|
- auto it = array.createIterator();
|
|
|
- if (!it.done()) {
|
|
|
+ size_t visitArray(VariantData* array) {
|
|
|
+ ARDUINOJSON_ASSERT(array != nullptr);
|
|
|
+ ARDUINOJSON_ASSERT(array->isArray());
|
|
|
+
|
|
|
+ auto slotId = array->content.asCollection.head;
|
|
|
+ if (slotId != NULL_SLOT) {
|
|
|
base::write("[\r\n");
|
|
|
nesting_++;
|
|
|
- while (!it.done()) {
|
|
|
+ while (slotId != NULL_SLOT) {
|
|
|
indent();
|
|
|
- VariantImpl::accept(*this, it.data(), base::resources_);
|
|
|
+ auto slot = base::resources_->getVariant(slotId);
|
|
|
+ VariantImpl::accept(*this, slot, base::resources_);
|
|
|
|
|
|
- it.next(base::resources_);
|
|
|
- base::write(it.done() ? "\r\n" : ",\r\n");
|
|
|
+ slotId = slot->next;
|
|
|
+ base::write(slotId == NULL_SLOT ? "\r\n" : ",\r\n");
|
|
|
}
|
|
|
nesting_--;
|
|
|
indent();
|
|
|
@@ -40,21 +44,25 @@ class PrettyJsonSerializer : public JsonSerializer<TWriter> {
|
|
|
return this->bytesWritten();
|
|
|
}
|
|
|
|
|
|
- size_t visit(const ObjectImpl& object) {
|
|
|
- auto it = object.createIterator();
|
|
|
- if (!it.done()) {
|
|
|
+ size_t visitObject(VariantData* object) {
|
|
|
+ ARDUINOJSON_ASSERT(object != nullptr);
|
|
|
+ ARDUINOJSON_ASSERT(object->isObject());
|
|
|
+
|
|
|
+ auto slotId = object->content.asCollection.head;
|
|
|
+ if (slotId != NULL_SLOT) {
|
|
|
base::write("{\r\n");
|
|
|
nesting_++;
|
|
|
bool isKey = true;
|
|
|
- while (!it.done()) {
|
|
|
+ while (slotId != NULL_SLOT) {
|
|
|
if (isKey)
|
|
|
indent();
|
|
|
- VariantImpl::accept(*this, it.data(), base::resources_);
|
|
|
- it.next(base::resources_);
|
|
|
+ auto slot = base::resources_->getVariant(slotId);
|
|
|
+ VariantImpl::accept(*this, slot, base::resources_);
|
|
|
+ slotId = slot->next;
|
|
|
if (isKey)
|
|
|
base::write(": ");
|
|
|
else
|
|
|
- base::write(it.done() ? "\r\n" : ",\r\n");
|
|
|
+ base::write(slotId == NULL_SLOT ? "\r\n" : ",\r\n");
|
|
|
isKey = !isKey;
|
|
|
}
|
|
|
nesting_--;
|