1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:08:13 +00:00

JSON: Templatize the JSON serialization code

This makes it possible to use something other than a StringBuilder for
serialization (and to produce something other than a String.) :^)
This commit is contained in:
Andreas Kling 2019-08-07 21:28:07 +02:00
parent 43ec733b61
commit f6998b1817
11 changed files with 145 additions and 109 deletions

View file

@ -2,6 +2,7 @@
#include <AK/JsonObject.h>
#include <AK/JsonValue.h>
#include <AK/LogStream.h>
#include <AK/StringBuilder.h>
#include <LibCore/CFile.h>
#include <stdio.h>
@ -70,7 +71,7 @@ int main(int argc, char** argv)
auto class_name = widget_object.get("class").to_string();
dbg() << " " << name << " = new " << class_name << "(main_widget);";
widget_object.for_each_member([&](auto& property_name, auto& property_value) {
widget_object.for_each_member([&](auto& property_name, const JsonValue& property_value) {
if (property_name == "class")
return;
@ -79,7 +80,7 @@ int main(int argc, char** argv)
if (property_value.is_null())
value = "{}";
else
value = property_value.serialized();
value = property_value.to_string();
dbg() << " " << name << "->set_" << property_name << "(" << value << ");";
});