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