mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-17 16:28:06 +03: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
Notes:
sideshowbarker
2024-07-19 13:33:10 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/aa3df518e73
@ -3,21 +3,21 @@
|
||||
|
||||
namespace AK {
|
||||
|
||||
void JsonArray::to_string(StringBuilder& builder) const
|
||||
void JsonArray::serialize(StringBuilder& builder) const
|
||||
{
|
||||
builder.append('[');
|
||||
for (int i = 0; i < m_values.size(); ++i) {
|
||||
m_values[i].to_string(builder);
|
||||
m_values[i].serialize(builder);
|
||||
if (i != size() - 1)
|
||||
builder.append(',');
|
||||
}
|
||||
builder.append(']');
|
||||
}
|
||||
|
||||
String JsonArray::to_string() const
|
||||
String JsonArray::serialized() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
to_string(builder);
|
||||
serialize(builder);
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
@ -19,8 +19,8 @@ public:
|
||||
void clear() { m_values.clear(); }
|
||||
void append(const JsonValue& value) { m_values.append(value); }
|
||||
|
||||
String to_string() const;
|
||||
void to_string(StringBuilder&) const;
|
||||
String serialized() const;
|
||||
void serialize(StringBuilder&) const;
|
||||
|
||||
private:
|
||||
Vector<JsonValue> m_values;
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
namespace AK {
|
||||
|
||||
void JsonObject::to_string(StringBuilder& builder) const
|
||||
void JsonObject::serialize(StringBuilder& builder) const
|
||||
{
|
||||
int index = 0;
|
||||
builder.append('{');
|
||||
@ -12,7 +12,7 @@ void JsonObject::to_string(StringBuilder& builder) const
|
||||
builder.append(key);
|
||||
builder.append('"');
|
||||
builder.append(':');
|
||||
value.to_string(builder);
|
||||
value.serialize(builder);
|
||||
if (index != size() - 1)
|
||||
builder.append(',');
|
||||
++index;
|
||||
@ -20,10 +20,10 @@ void JsonObject::to_string(StringBuilder& builder) const
|
||||
builder.append('}');
|
||||
}
|
||||
|
||||
String JsonObject::to_string() const
|
||||
String JsonObject::serialized() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
to_string(builder);
|
||||
serialize(builder);
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
@ -40,8 +40,8 @@ public:
|
||||
callback(it.key, it.value);
|
||||
}
|
||||
|
||||
String to_string() const;
|
||||
void to_string(StringBuilder&) const;
|
||||
String serialized() const;
|
||||
void serialize(StringBuilder&) const;
|
||||
|
||||
private:
|
||||
HashMap<String, JsonValue> m_members;
|
||||
|
@ -136,17 +136,17 @@ void JsonValue::clear()
|
||||
m_value.as_string = nullptr;
|
||||
}
|
||||
|
||||
void JsonValue::to_string(StringBuilder& builder) const
|
||||
void JsonValue::serialize(StringBuilder& builder) const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::String:
|
||||
builder.appendf("\"%s\"", m_value.as_string->characters());
|
||||
break;
|
||||
case Type::Array:
|
||||
m_value.as_array->to_string(builder);
|
||||
m_value.as_array->serialize(builder);
|
||||
break;
|
||||
case Type::Object:
|
||||
m_value.as_object->to_string(builder);
|
||||
m_value.as_object->serialize(builder);
|
||||
break;
|
||||
case Type::Bool:
|
||||
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;
|
||||
to_string(builder);
|
||||
serialize(builder);
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ public:
|
||||
JsonValue(const JsonArray&);
|
||||
JsonValue(const JsonObject&);
|
||||
|
||||
String to_string() const;
|
||||
void to_string(StringBuilder&) const;
|
||||
String serialized() const;
|
||||
void serialize(StringBuilder&) const;
|
||||
|
||||
String as_string() const
|
||||
{
|
||||
|
@ -329,7 +329,7 @@ void VBForm::write_to_file(const String& path)
|
||||
widget_array.append(widget_object);
|
||||
}
|
||||
form_object.set("widgets", widget_array);
|
||||
file.write(form_object.to_string());
|
||||
file.write(form_object.serialized());
|
||||
}
|
||||
|
||||
void VBForm::dump()
|
||||
|
Loading…
Reference in New Issue
Block a user