1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 17:44:56 +09:00

JSON: Port JsonArray and JsonObject serialization to serializers

This way, primitive JsonValue serialization is still handled by
JsonValue::serialize(), but JsonArray and JsonObject serialization
always goes through serializer classes. This is no less efficient
if you have the whole JSON in memory already.
This commit is contained in:
Sergey Bugaev 2019-08-27 14:15:30 +03:00 committed by Andreas Kling
parent 56f5c14d86
commit 216b7b3b80
Notes: sideshowbarker 2024-07-19 12:29:34 +09:00
2 changed files with 6 additions and 18 deletions

View file

@ -1,5 +1,6 @@
#pragma once
#include <AK/JsonArraySerializer.h>
#include <AK/JsonValue.h>
#include <AK/Vector.h>
@ -68,13 +69,8 @@ private:
template<typename Builder>
inline void JsonArray::serialize(Builder& builder) const
{
builder.append('[');
for (int i = 0; i < m_values.size(); ++i) {
m_values[i].serialize(builder);
if (i != size() - 1)
builder.append(',');
}
builder.append(']');
JsonArraySerializer serializer { builder };
for_each([&](auto& value) { serializer.add(value); });
}
template<typename Builder>