diff options
author | Emmanuele Bassi <ebassi@linux.intel.com> | 2011-06-01 12:49:28 +0100 |
---|---|---|
committer | Emmanuele Bassi <ebassi@linux.intel.com> | 2011-06-01 12:49:28 +0100 |
commit | e3b5883d4435da7fe677eb9a7c74d2f83980f5da (patch) | |
tree | 24cefde408083904eaf4716bdf6ccc28672cc7b3 /json-glib/json-gobject.c | |
parent | 8c424cc133575282371bff8d17295662267049e9 (diff) | |
download | json-glib-e3b5883d4435da7fe677eb9a7c74d2f83980f5da.tar.gz |
gobject: Do not serialize default values
If a property is set to its default value then we can skip its
serialization, to keep the number of JSON object members down.
Diffstat (limited to 'json-glib/json-gobject.c')
-rw-r--r-- | json-glib/json-gobject.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/json-glib/json-gobject.c b/json-glib/json-gobject.c index fb97bd4..fbc6efc 100644 --- a/json-glib/json-gobject.c +++ b/json-glib/json-gobject.c @@ -398,6 +398,13 @@ 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 |