2019-06-17 17:47:35 +00:00
|
|
|
#include <AK/JsonObject.h>
|
|
|
|
#include <AK/StringBuilder.h>
|
|
|
|
|
2019-06-17 19:34:12 +00:00
|
|
|
namespace AK {
|
|
|
|
|
|
|
|
void JsonObject::to_string(StringBuilder& builder) const
|
2019-06-17 17:47:35 +00:00
|
|
|
{
|
|
|
|
int index = 0;
|
|
|
|
builder.append('{');
|
|
|
|
for_each_member([&] (auto& key, auto& value) {
|
|
|
|
builder.append('"');
|
|
|
|
builder.append(key);
|
|
|
|
builder.append('"');
|
|
|
|
builder.append(':');
|
2019-06-17 19:34:12 +00:00
|
|
|
value.to_string(builder);
|
2019-06-17 17:47:35 +00:00
|
|
|
if (index != size() - 1)
|
|
|
|
builder.append(',');
|
|
|
|
++index;
|
|
|
|
});
|
|
|
|
builder.append('}');
|
2019-06-17 19:34:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
String JsonObject::to_string() const
|
|
|
|
{
|
|
|
|
StringBuilder builder;
|
|
|
|
to_string(builder);
|
2019-06-17 17:47:35 +00:00
|
|
|
return builder.to_string();
|
|
|
|
}
|
2019-06-17 19:34:12 +00:00
|
|
|
|
|
|
|
}
|