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:
parent
56f5c14d86
commit
216b7b3b80
Notes:
sideshowbarker
2024-07-19 12:29:34 +09:00
Author: https://github.com/bugaevc
Commit: 216b7b3b80
Pull-request: https://github.com/SerenityOS/serenity/pull/489
Reviewed-by: https://github.com/awesomekling
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