mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 19:47:46 +00: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:
parent
56f5c14d86
commit
216b7b3b80
2 changed files with 6 additions and 18 deletions
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue