mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:48:10 +00:00
AK: Rename JsonObject::to_string() and pals to serialized().
And the variant that serializes into a StringBuilder is called serialize().
This commit is contained in:
parent
15fa4f1c55
commit
aa3df518e7
7 changed files with 20 additions and 20 deletions
|
@ -3,21 +3,21 @@
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
void JsonArray::to_string(StringBuilder& builder) const
|
void JsonArray::serialize(StringBuilder& builder) const
|
||||||
{
|
{
|
||||||
builder.append('[');
|
builder.append('[');
|
||||||
for (int i = 0; i < m_values.size(); ++i) {
|
for (int i = 0; i < m_values.size(); ++i) {
|
||||||
m_values[i].to_string(builder);
|
m_values[i].serialize(builder);
|
||||||
if (i != size() - 1)
|
if (i != size() - 1)
|
||||||
builder.append(',');
|
builder.append(',');
|
||||||
}
|
}
|
||||||
builder.append(']');
|
builder.append(']');
|
||||||
}
|
}
|
||||||
|
|
||||||
String JsonArray::to_string() const
|
String JsonArray::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
to_string(builder);
|
serialize(builder);
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,8 @@ public:
|
||||||
void clear() { m_values.clear(); }
|
void clear() { m_values.clear(); }
|
||||||
void append(const JsonValue& value) { m_values.append(value); }
|
void append(const JsonValue& value) { m_values.append(value); }
|
||||||
|
|
||||||
String to_string() const;
|
String serialized() const;
|
||||||
void to_string(StringBuilder&) const;
|
void serialize(StringBuilder&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vector<JsonValue> m_values;
|
Vector<JsonValue> m_values;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
namespace AK {
|
namespace AK {
|
||||||
|
|
||||||
void JsonObject::to_string(StringBuilder& builder) const
|
void JsonObject::serialize(StringBuilder& builder) const
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
builder.append('{');
|
builder.append('{');
|
||||||
|
@ -12,7 +12,7 @@ void JsonObject::to_string(StringBuilder& builder) const
|
||||||
builder.append(key);
|
builder.append(key);
|
||||||
builder.append('"');
|
builder.append('"');
|
||||||
builder.append(':');
|
builder.append(':');
|
||||||
value.to_string(builder);
|
value.serialize(builder);
|
||||||
if (index != size() - 1)
|
if (index != size() - 1)
|
||||||
builder.append(',');
|
builder.append(',');
|
||||||
++index;
|
++index;
|
||||||
|
@ -20,10 +20,10 @@ void JsonObject::to_string(StringBuilder& builder) const
|
||||||
builder.append('}');
|
builder.append('}');
|
||||||
}
|
}
|
||||||
|
|
||||||
String JsonObject::to_string() const
|
String JsonObject::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
to_string(builder);
|
serialize(builder);
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,8 +40,8 @@ public:
|
||||||
callback(it.key, it.value);
|
callback(it.key, it.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
String to_string() const;
|
String serialized() const;
|
||||||
void to_string(StringBuilder&) const;
|
void serialize(StringBuilder&) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HashMap<String, JsonValue> m_members;
|
HashMap<String, JsonValue> m_members;
|
||||||
|
|
|
@ -136,17 +136,17 @@ void JsonValue::clear()
|
||||||
m_value.as_string = nullptr;
|
m_value.as_string = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonValue::to_string(StringBuilder& builder) const
|
void JsonValue::serialize(StringBuilder& builder) const
|
||||||
{
|
{
|
||||||
switch (m_type) {
|
switch (m_type) {
|
||||||
case Type::String:
|
case Type::String:
|
||||||
builder.appendf("\"%s\"", m_value.as_string->characters());
|
builder.appendf("\"%s\"", m_value.as_string->characters());
|
||||||
break;
|
break;
|
||||||
case Type::Array:
|
case Type::Array:
|
||||||
m_value.as_array->to_string(builder);
|
m_value.as_array->serialize(builder);
|
||||||
break;
|
break;
|
||||||
case Type::Object:
|
case Type::Object:
|
||||||
m_value.as_object->to_string(builder);
|
m_value.as_object->serialize(builder);
|
||||||
break;
|
break;
|
||||||
case Type::Bool:
|
case Type::Bool:
|
||||||
builder.append(m_value.as_bool ? "true" : "false");
|
builder.append(m_value.as_bool ? "true" : "false");
|
||||||
|
@ -168,10 +168,10 @@ void JsonValue::to_string(StringBuilder& builder) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String JsonValue::to_string() const
|
String JsonValue::serialized() const
|
||||||
{
|
{
|
||||||
StringBuilder builder;
|
StringBuilder builder;
|
||||||
to_string(builder);
|
serialize(builder);
|
||||||
return builder.to_string();
|
return builder.to_string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,8 +39,8 @@ public:
|
||||||
JsonValue(const JsonArray&);
|
JsonValue(const JsonArray&);
|
||||||
JsonValue(const JsonObject&);
|
JsonValue(const JsonObject&);
|
||||||
|
|
||||||
String to_string() const;
|
String serialized() const;
|
||||||
void to_string(StringBuilder&) const;
|
void serialize(StringBuilder&) const;
|
||||||
|
|
||||||
String as_string() const
|
String as_string() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -329,7 +329,7 @@ void VBForm::write_to_file(const String& path)
|
||||||
widget_array.append(widget_object);
|
widget_array.append(widget_object);
|
||||||
}
|
}
|
||||||
form_object.set("widgets", widget_array);
|
form_object.set("widgets", widget_array);
|
||||||
file.write(form_object.to_string());
|
file.write(form_object.serialized());
|
||||||
}
|
}
|
||||||
|
|
||||||
void VBForm::dump()
|
void VBForm::dump()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue