No subject


Wed Jun 27 05:48:46 CEST 2012


libjson-c.

2013/1/26 Matthew Williams <matthew at flowroute.com>

> Last night I pushed an updated json module to branch mgw/json. It has
> significant improvements over the previous version, including:
>
> * A way to access nested elements, using a subset of JSONPath.
> * The ability to loop over arrays
>
> Note that there is a change in the external dependency from libjson-c to
> libjansson.
>
> Matthew Williams
>
>
>
> Documentation:
>
>
> JSON Module
>
> Joe Hillenbrand
>
>    <joe at flowroute.com>
>
> Edited by
>
> Matthew Williams
>
>    <matthew at flowroute.com>
>
>    Copyright =A9 2013 Flowroute LLC (flowroute.com)
>      __________________________________________________________________
>
>    Table of Contents
>
>    1. Admin Guide
>
>         1. Overview
>         2. Dependencies
>
>               2.1. Kamailio Modules
>               2.2. External Libraries or Applications
>
>         3. Parameters
>
>               3.1.
>
>         4. Functions
>
>               4.1. json_path_get(json_string, json_path, destination)
>               4.2. json_array_size(json_string, json_path, destination)
>               4.3. json_get_field(json_string, field_name, destination)
>
>    List of Examples
>
>    1.1. json_path_get usage
>    1.2. json_array_size usage
>     1.3. json_get_field usage
>
> Chapter 1. Admin Guide
>
>    Table of Contents
>
>    1. Overview
>    2. Dependencies
>
>         2.1. Kamailio Modules
>         2.2. External Libraries or Applications
>
>    3. Parameters
>
>         3.1.
>
>    4. Functions
>
>         4.1. json_path_get(json_string, json_path, destination)
>         4.2. json_array_size(json_string, json_path, destination)
>         4.3. json_get_field(json_string, field_name, destination)
>
> 1. Overview
>
>    This module provides operations on json strings.
>
> 2. Dependencies
>
>    2.1. Kamailio Modules
>    2.2. External Libraries or Applications
>
> 2.1. Kamailio Modules
>
>    The following modules must be loaded before this module:
>      * None
>
> 2.2. External Libraries or Applications
>
>    The following libraries or applications must be installed before
>    running Kamailio with this module loaded:
>      * jansson (http://www.digip.org/jansson/), tested with: 2.2+
>
> 3. Parameters
>
>    3.1.
>
>    None
>
> 4. Functions
>
>    4.1. json_path_get(json_string, json_path, destination)
>    4.2. json_array_size(json_string, json_path, destination)
>    4.3. json_get_field(json_string, field_name, destination)
>
> 4.1.  json_path_get(json_string, json_path, destination)
>
>    Copy the value at the path from json object 'json_string' and store it
>    in pvar 'destination'.
>
>    The path string supports dot delimited notation (e.g. foo.bar.baz),
>    array notation (e.g. list[0]), or a combination of the two (e.g.
>    foo.bar[0][1].baz).
>
>    The function can put a string, integer, null, or new json string into
>    destination.
>
>    Example 1.1. json_path_get usage
> ...
> json_path_get($var(myjson), "inner.deep.num", "$var(n)");
> xlog("foo is $var(n)");
> ...
>
> 4.2.  json_array_size(json_string, json_path, destination)
>
>    Puts size of the array in 'json_string' at 'json_path' into the pvar
>    'destination'.
>
>    This is particularly useful for looping through an array. See example.
>
>    Example 1.2. json_array_size usage
> ...
> $var(array) =3D "{\"loopme\":[0,1,2,3,4,5]}";
> $var(count) =3D 0;
> json_array_size($var(array), "loopme", "$var(size)");
> while($var(count) < $var(size)) {
>     json_path_get($var(array), "loopme[$var(count)]", "$var(v)");
>     xlog("loopme[$var(count)] =3D=3D $var(v)\n");
>     $var(count) =3D $var(count) + 1;
> }
> ...
>
> 4.3.  json_get_field(json_string, field_name, destination)
>
>    Copy field 'field_name' from json object 'json_string' and store it in
>    pvar 'destination'.
>
>    This function is deprecated but kept for backwards compatibility. Righ=
t
>    now it is just a wrapper around json_path_get, and its functionality i=
s
>    the same.
>
>    Example 1.3. json_get_field usage
> ...
> json_get_field("{'foo':'bar'}", "foo", "$var(foo)");
> xlog("foo is $var(foo)");
> ...
>
> _______________________________________________
> sr-dev mailing list
> sr-dev at lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
>
>

--20cf3071ceceef3d7c04d4350d3d
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable



More information about the sr-dev mailing list