After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 621141 - JsonBuilder
JsonBuilder
Status: RESOLVED FIXED
Product: json-glib
Classification: Core
Component: Core
git master
Other Linux
: Normal enhancement
: ---
Assigned To: json-glib-maint
json-glib-maint
Depends on:
Blocks:
 
 
Reported: 2010-06-09 19:29 UTC by Luca Bruno
Modified: 2012-03-13 22:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
JsonBuilder component for json-glib (27.29 KB, patch)
2010-06-09 19:31 UTC, Luca Bruno
reviewed Details | Review
JsonBuilder component for json-glib updated (29.21 KB, patch)
2010-06-10 21:01 UTC, Luca Bruno
committed Details | Review

Description Luca Bruno 2010-06-09 19:29:19 UTC
Convenience builder API for creating JSON trees.
Comment 1 Luca Bruno 2010-06-09 19:31:51 UTC
Created attachment 163227 [details] [review]
JsonBuilder component for json-glib

Inspired by http://www.json.org/javadoc/org/json/JSONWriter.html
Comment 2 Emmanuele Bassi (:ebassi) 2010-06-10 12:00:26 UTC
Review of attachment 163227 [details] [review]:

looks good, except for two minor points

::: json-glib/json-builder.c
@@ +183,3 @@
+ * This call automatically reduces the reference count on builder by one.
+ * Unless you've taken other actions, this is usually sufficient to free builder.
+ *

I'm not a fan of this "close to unref" behaviour.

I'd much prefer close() to behave like GChecksum in GLib: maintain the JsonNode until json_build_reset() is called - a method which will allow to start from scratch re-using the same JsonBuilder instance. this also means adding a json_builder_get_root()  or json_builder_get_node(), returning the root node.

::: json-glib/tests/builder-test.c
@@ +35,3 @@
+
+  json_builder_add_string_value (builder, "after array");
+  json_builder_end_array (builder); // depth2

please, no C99
Comment 3 Luca Bruno 2010-06-10 21:01:43 UTC
Created attachment 163333 [details] [review]
JsonBuilder component for json-glib updated

- Removed close(), added get_root() and reset().
- Added /builder/reset test.
Comment 4 Emmanuele Bassi (:ebassi) 2010-06-16 11:09:21 UTC
Attachment 163333 [details] pushed to json-glib master
Comment 5 André Klapper 2012-03-13 22:08:45 UTC
[Fixing Default QA assignee for json-glib - see 613232#c1. Sorry for bugmail noise.]