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 773410 - Add JCON, JSON C Object Notation
Add JCON, JSON C Object Notation
Status: RESOLVED OBSOLETE
Product: json-glib
Classification: Core
Component: general
git master
Other Linux
: Normal normal
: ---
Assigned To: json-glib-maint
json-glib-maint
Depends on:
Blocks:
 
 
Reported: 2016-10-24 09:18 UTC by Christian Hergert
Modified: 2017-09-05 10:42 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
build: bump for development version (2.60 KB, patch)
2016-10-24 09:19 UTC, Christian Hergert
none Details | Review
jcon: add "JavaScript C Object Notation" (28.14 KB, patch)
2016-10-24 09:19 UTC, Christian Hergert
none Details | Review

Description Christian Hergert 2016-10-24 09:18:31 UTC
Adding a bug here to track support for JCON.

I'm going to attach patches for JCON support. I don't expect them to be committed as is, but figured I'd land things here as a place for us to collaborate on features and make progress.

One thing I don't like about the current implementation is the difference of JCON_STRING() vs JCONE_STRING() (for all the data types). I think we can unify these macros and do the right thing based on the context of either creation (JCON_NEW) or extraction (JCON_EXTRACT).

Feel free to iterate on the patches, or let me know and I can find some time to do it.
Comment 1 Christian Hergert 2016-10-24 09:19:26 UTC
Created attachment 338327 [details] [review]
build: bump for development version
Comment 2 Christian Hergert 2016-10-24 09:19:31 UTC
Created attachment 338328 [details] [review]
jcon: add "JavaScript C Object Notation"

JCON provides a simplified interface to creating and parsing known JSON
document schemas. This is performed using the combination of va_list and
struct initializers.

It is not necessarily as safe as the static typing we would get from
imperative use of the JsonNode APIs, but it does provide a clarity of
syntax in the source files that is more easily code reviewed.

We might consider adding more stringent checks in the future based on
common errors we see. For example, I anticipate the wrong use of
JCON_STRING vs JCONE_STRING() depending on the context. There might be
further opportunity to unify these two macros into a single that always
takes a pointer to the target location, with one doing a read and one
doing a write basedon JCON_NEW() vs JCON_EXTRACT().

See json-glib/tests/jcon.c for example usage.
Comment 3 Emmanuele Bassi (:ebassi) 2017-04-16 11:51:31 UTC
I like it very much.

It'll need to be updated to use Meson, now that we dropped autotools from master; it'll also need to be skipped from introspection.

The main issue I see is that gtk-doc will likely choke on the namespace.
Comment 4 Christian Hergert 2017-04-16 21:59:49 UTC
(In reply to Emmanuele Bassi (:ebassi) from comment #3)
> The main issue I see is that gtk-doc will likely choke on the namespace.

Indeed. For Jsonrpc-Glib, I ported the public API to GVariant (so I can avoid JSON parsing with known peers). So I had to port JCON to GVariant. In that form, I namespaced things like:

  JSONPRC_MESSAGE_NEW()
  JSONRPC_MESSAGE_PARSE()

and the to clarify in/out directions:

  JSONRPC_MESSAGE_GET_STRING (&foostr)
  JSONRPC_MESSAGE_PUT_STRING (foostr)

so that we get a modicum of type safety.
Comment 5 Emmanuele Bassi (:ebassi) 2017-09-05 10:42:31 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/json-glib/issues/18.