mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
aa3df518e7
And the variant that serializes into a StringBuilder is called serialize().
30 lines
625 B
C++
30 lines
625 B
C++
#include <AK/JsonObject.h>
|
|
#include <AK/StringBuilder.h>
|
|
|
|
namespace AK {
|
|
|
|
void JsonObject::serialize(StringBuilder& builder) const
|
|
{
|
|
int index = 0;
|
|
builder.append('{');
|
|
for_each_member([&] (auto& key, auto& value) {
|
|
builder.append('"');
|
|
builder.append(key);
|
|
builder.append('"');
|
|
builder.append(':');
|
|
value.serialize(builder);
|
|
if (index != size() - 1)
|
|
builder.append(',');
|
|
++index;
|
|
});
|
|
builder.append('}');
|
|
}
|
|
|
|
String JsonObject::serialized() const
|
|
{
|
|
StringBuilder builder;
|
|
serialize(builder);
|
|
return builder.to_string();
|
|
}
|
|
|
|
}
|