mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:27:35 +00:00
JSON: Templatize the JSON serialization code
This makes it possible to use something other than a StringBuilder for serialization (and to produce something other than a String.) :^)
This commit is contained in:
parent
43ec733b61
commit
f6998b1817
11 changed files with 145 additions and 109 deletions
|
@ -3,22 +3,4 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
void JsonArray::serialize(StringBuilder& 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(']');
|
||||
}
|
||||
|
||||
String JsonArray::serialized() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
serialize(builder);
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue