mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 19:19:30 +00:00
AK+Everywhere: Convert JSON value serialization to String
This removes the use of StringBuilder::OutputType (which was ByteString, and only used by the JSON classes). And it removes the StringBuilder template parameter from the serialization methods; this was only ever used with StringBuilder, so a template is pretty overkill here.
This commit is contained in:
parent
2c03de60da
commit
fe2dff4944
Notes:
github-actions[bot]
2025-02-21 00:28:53 +00:00
Author: https://github.com/trflynn89
Commit: fe2dff4944
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3631
Reviewed-by: https://github.com/awesomekling ✅
15 changed files with 98 additions and 95 deletions
|
@ -8,8 +8,8 @@
|
|||
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/JsonArraySerializer.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
|
||||
namespace AK {
|
||||
|
@ -72,11 +72,8 @@ public:
|
|||
ErrorOr<void> append(JsonValue value) { return m_values.try_append(move(value)); }
|
||||
void set(size_t index, JsonValue value) { m_values.at(index) = move(value); }
|
||||
|
||||
template<typename Builder>
|
||||
typename Builder::OutputType serialized() const;
|
||||
|
||||
template<typename Builder>
|
||||
void serialize(Builder&) const;
|
||||
String serialized() const;
|
||||
void serialize(StringBuilder&) const;
|
||||
|
||||
template<typename Callback>
|
||||
void for_each(Callback callback)
|
||||
|
@ -118,22 +115,6 @@ private:
|
|||
Vector<JsonValue> m_values;
|
||||
};
|
||||
|
||||
template<typename Builder>
|
||||
inline void JsonArray::serialize(Builder& builder) const
|
||||
{
|
||||
auto serializer = MUST(JsonArraySerializer<>::try_create(builder));
|
||||
for_each([&](auto& value) { MUST(serializer.add(value)); });
|
||||
MUST(serializer.finish());
|
||||
}
|
||||
|
||||
template<typename Builder>
|
||||
inline typename Builder::OutputType JsonArray::serialized() const
|
||||
{
|
||||
Builder builder;
|
||||
serialize(builder);
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if USING_AK_GLOBALLY
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue