blob: f3b53be49e5bdedd5c88ee3adf72a73b34e76f91 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#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();
}
}
|