diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-07-09 15:23:36 -0400 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2011-07-09 15:23:36 -0400 |
commit | 4315308a19e4cf474451cecf8b69aceddda91f49 (patch) | |
tree | 226d181df9ea9dcbb768bd20071e3ab2a84ddd7b /json-glib/json-gobject.c | |
parent | 4ba9a6a81709221ba58d0f8e067de660eb96914e (diff) | |
download | json-glib-4315308a19e4cf474451cecf8b69aceddda91f49.tar.gz |
Avoid serializing default property values only after
consulting the JsonSerializable.
This patch gives the JsonSerializable class a chance to decide
whether it's appropriate to serialize a property before
JsonGObject checks for a default value and skips the property.
Diffstat (limited to 'json-glib/json-gobject.c')
-rw-r--r-- | json-glib/json-gobject.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/json-glib/json-gobject.c b/json-glib/json-gobject.c index 73ecaac..0b91a5e 100644 --- a/json-glib/json-gobject.c +++ b/json-glib/json-gobject.c @@ -400,13 +400,6 @@ json_gobject_dump (GObject *gobject) else g_object_get_property (gobject, pspec->name, &value); - /* skip if the value is the default for the property */ - if (g_param_value_defaults (pspec, &value)) - { - g_value_unset (&value); - continue; - } - /* if there is a serialization vfunc, then it is completely responsible * for serializing the property, possibly by calling the implementation * of the default JsonSerializable interface through chaining up @@ -417,7 +410,8 @@ json_gobject_dump (GObject *gobject) &value, pspec); } - else + /* skip if the value is the default for the property */ + else if (!g_param_value_defaults (pspec, &value)) node = json_serialize_pspec (&value, pspec); if (node) |