From aa3df518e73992defafe58b025f36c6bfae436cd Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 18 Jun 2019 09:37:47 +0200 Subject: [PATCH] AK: Rename JsonObject::to_string() and pals to serialized(). And the variant that serializes into a StringBuilder is called serialize(). --- AK/JsonArray.cpp | 8 ++++---- AK/JsonArray.h | 4 ++-- AK/JsonObject.cpp | 8 ++++---- AK/JsonObject.h | 4 ++-- AK/JsonValue.cpp | 10 +++++----- AK/JsonValue.h | 4 ++-- DevTools/VisualBuilder/VBForm.cpp | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/AK/JsonArray.cpp b/AK/JsonArray.cpp index 2cba65cbf3..2a877c1df5 100644 --- a/AK/JsonArray.cpp +++ b/AK/JsonArray.cpp @@ -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(); } diff --git a/AK/JsonArray.h b/AK/JsonArray.h index e67a731fe8..d2f403c4ec 100644 --- a/AK/JsonArray.h +++ b/AK/JsonArray.h @@ -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 m_values; diff --git a/AK/JsonObject.cpp b/AK/JsonObject.cpp index 7817dc937e..f3b53be49e 100644 --- a/AK/JsonObject.cpp +++ b/AK/JsonObject.cpp @@ -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(); } diff --git a/AK/JsonObject.h b/AK/JsonObject.h index 42810e8497..a47d5a9c2b 100644 --- a/AK/JsonObject.h +++ b/AK/JsonObject.h @@ -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 m_members; diff --git a/AK/JsonValue.cpp b/AK/JsonValue.cpp index 0cf0760304..4c8b22a14b 100644 --- a/AK/JsonValue.cpp +++ b/AK/JsonValue.cpp @@ -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(); } diff --git a/AK/JsonValue.h b/AK/JsonValue.h index 2d37614513..50ddcf49c6 100644 --- a/AK/JsonValue.h +++ b/AK/JsonValue.h @@ -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 { diff --git a/DevTools/VisualBuilder/VBForm.cpp b/DevTools/VisualBuilder/VBForm.cpp index 71aea3ab16..18cd06f7fb 100644 --- a/DevTools/VisualBuilder/VBForm.cpp +++ b/DevTools/VisualBuilder/VBForm.cpp @@ -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()