[asterisk-dev] [Code Review]: Add JSON support to Asterisk

David Lee reviewboard at asterisk.org
Wed Jan 9 23:45:34 CST 2013



> On Jan. 7, 2013, 3:56 p.m., elguero wrote:
> > /trunk/contrib/scripts/install_prereq, line 30
> > <https://reviewboard.asterisk.org/r/2264/diff/1/?file=32588#file32588line30>
> >
> >     Is there a Jansson library package for RHEL?  I see one in Fedora 17 but I do not seem to find one for CentOS 6 (RHEL 6).
> >     
> >     Yet, there is json-c for both Debian and RHEL.
> >     
> >     Was there a particular reason why we chose Jansson?  I hope I am not rehashing something that was already discussed and a decision was already made.  If so, then just ignore me.
> 
> David Lee wrote:
>     I picked Jansson on a recommendation, and its straightforward API. If there was one thing that sold me on Jansson, it was the json_pack[1] function, which is a simple and excellent way to build JSON objects.
>     
>     I'll look into the availability issue for RHEL. I'm open to using json-c, but not if that means giving up json_pack. I don't immediately see an equivalent in json-c. Do you know of one?
>     
>      [1]: http://www.digip.org/jansson/doc/2.4/apiref.html#building-values
> 
> elguero wrote:
>     My main concern is the availability.  Other than that, Jansson does look like a very good library.
>     
>     I looked into json-c for building a JSON object and it doesn't look too bad[1].  I did find some tutorials[2] that gave some simple explanations on how to build JSON objects[3].  I do not quite see an equivalent to json_pack, though.  
>     
>     [1]: http://json-c.github.com/json-c/json-c-0.10/doc/html/json__object_8h.html#a2025bc677c35f130e117dfda5bf1ef73
>     [2]: https://linuxprograms.wordpress.com/tag/json_object_to_json_string/
>     [3]: https://linuxprograms.wordpress.com/2010/08/19/json_object_new_object/

The jansson.spec file from Fedora[1] is very straightforward. It's only build dependency (python-sphinx) is in EL6, so providing Jansson RPM's shouldn't be difficult.

 [1]: http://pkgs.fedoraproject.org/cgit/jansson.git/tree/jansson.spec


- David


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2264/#review7626
-----------------------------------------------------------


On Jan. 9, 2013, 11:26 p.m., David Lee wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2264/
> -----------------------------------------------------------
> 
> (Updated Jan. 9, 2013, 11:26 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> This provides a JSON API by pulling in and wrapping the Jansson JSON
> library[1]. The Asterisk API basically mirrors the Jansson
> functionality, with a few minor tweaks:
> 
>  * Jansson provides both reference-stealing and reference-borrowing
>    versions of several API's. The Asterisk API is exclusively
>    reference-stealing for operations that put elements into arrays and
>    objects.
>  * No support for doubles, since we usually don't need that.
>  * Coming along for the ride is the ast_test_check macro, which makes
>    it easier to accumulate the results of several operations in a test.
> 
>  [1]: http://www.digip.org/jansson/
> 
> 
> This addresses bug ASTERISK-20888.
>     https://issues.asterisk.org/jira/browse/ASTERISK-20888
> 
> 
> Diffs
> -----
> 
>   /trunk/build_tools/menuselect-deps.in 378906 
>   /trunk/configure.ac 378906 
>   /trunk/contrib/scripts/install_prereq 378906 
>   /trunk/include/asterisk/autoconfig.h.in 378906 
>   /trunk/include/asterisk/json.h PRE-CREATION 
>   /trunk/include/asterisk/test.h 378906 
>   /trunk/main/Makefile 378906 
>   /trunk/main/test.c 378906 
>   /trunk/makeopts.in 378906 
>   /trunk/res/res_json.c PRE-CREATION 
>   /trunk/res/res_json.exports.in PRE-CREATION 
>   /trunk/tests/test_json.c PRE-CREATION 
> 
> Diff: https://reviewboard.asterisk.org/r/2264/diff
> 
> 
> Testing
> -------
> 
> Behold, extensive unit tests!
> 
> 
> Thanks,
> 
> David
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20130110/b117596a/attachment.htm>


More information about the asterisk-dev mailing list