No subject


Wed Jun 27 05:48:46 CEST 2012


ibjson-c. <br><br><div class=3D"gmail_quote">2013/1/26 Matthew Williams <sp=
an dir=3D"ltr">&lt;<a href=3D"mailto:matthew at flowroute.com" target=3D"_blan=
k">matthew at flowroute.com</a>&gt;</span><br>

<blockquote class=3D"gmail_quote" style=3D"margin:0pt 0pt 0pt 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">Last night I pushed an up=
dated 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 JSONPat=
h.</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</di=
v><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><di=
v>Joe Hillenbrand</div><div><br></div><div>=A0 =A0&lt;<a href=3D"mailto:joe=
@flowroute.com" target=3D"_blank">joe at flowroute.com</a>&gt;</div><div><br><=
/div>

<div>Edited by</div>
<div><br></div><div>Matthew Williams</div><div><br></div><div>=A0 =A0&lt;<a=
 href=3D"mailto:matthew at flowroute.com" target=3D"_blank">matthew at flowroute.=
com</a>&gt;</div><div><br></div><div>=A0 =A0Copyright =A9 2013 Flowroute LL=
C (<a href=3D"http://flowroute.com" target=3D"_blank">flowroute.com</a>)</d=
iv>


<div>=A0 =A0 =A0___________________________________________________________=
_______</div><div><br></div><div>=A0 =A0Table of Contents</div><div><br></d=
iv><div>=A0 =A01. Admin Guide</div><div><br></div><div>=A0 =A0 =A0 =A0 1. O=
verview</div><div>


=A0 =A0 =A0 =A0 2. Dependencies</div><div><br></div><div>=A0 =A0 =A0 =A0 =
=A0 =A0 =A0 2.1. Kamailio Modules</div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 2.2=
. External Libraries or Applications</div><div><br></div><div>=A0 =A0 =A0 =
=A0 3. Parameters</div><div><br></div><div>


=A0 =A0 =A0 =A0 =A0 =A0 =A0 3.1.</div><div><br></div><div>=A0 =A0 =A0 =A0 4=
. Functions</div><div><br></div><div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 4.1. json_=
path_get(json_string, json_path, destination)</div><div>=A0 =A0 =A0 =A0 =A0=
 =A0 =A0 4.2. json_array_size(json_string, json_path, destination)</div>


<div>=A0 =A0 =A0 =A0 =A0 =A0 =A0 4.3. json_get_field(json_string, field_nam=
e, destination)</div><div><br></div><div>=A0 =A0List of Examples</div><div>=
<br></div><div>=A0 =A01.1. json_path_get usage</div><div>=A0 =A01.2. json_a=
rray_size usage</div>

<div>
=A0 =A01.3. json_get_field usage</div><div><br></div><div>Chapter 1. Admin =
Guide</div><div><br></div><div>=A0 =A0Table of Contents</div><div><br></div=
><div>=A0 =A01. Overview</div><div>=A0 =A02. Dependencies</div><div><br></d=
iv><div>=A0 =A0 =A0 =A0 2.1. Kamailio Modules</div>


<div>=A0 =A0 =A0 =A0 2.2. External Libraries or Applications</div><div><br>=
</div><div>=A0 =A03. Parameters</div><div><br></div><div>=A0 =A0 =A0 =A0 3.=
1.</div><div><br></div><div>=A0 =A04. Functions</div><div><br></div><div>=
=A0 =A0 =A0 =A0 4.1. json_path_get(json_string, json_path, destination)</di=
v>


<div>=A0 =A0 =A0 =A0 4.2. json_array_size(json_string, json_path, destinati=
on)</div><div>=A0 =A0 =A0 =A0 4.3. json_get_field(json_string, field_name, =
destination)</div><div><br></div><div>1. Overview</div><div><br></div><div>=
=A0 =A0This module provides operations on json strings.</div>


<div><br></div><div>2. Dependencies</div><div><br></div><div>=A0 =A02.1. Ka=
mailio Modules</div><div>=A0 =A02.2. External Libraries or Applications</di=
v><div><br></div><div>2.1. Kamailio Modules</div><div><br></div><div>=A0 =
=A0The following modules must be loaded before this module:</div>


<div>=A0 =A0 =A0* None</div><div><br></div><div>2.2. External Libraries or =
Applications</div><div><br></div><div>=A0 =A0The following libraries or app=
lications must be installed before</div><div>=A0 =A0running Kamailio with t=
his module loaded:</div>


<div>=A0 =A0 =A0* jansson (<a href=3D"http://www.digip.org/jansson/" target=
=3D"_blank">http://www.digip.org/jansson/</a>), tested with: 2.2+</div><div=
><br></div><div>3. Parameters</div><div><br></div><div>=A0 =A03.1.</div><di=
v><br></div>

<div>=A0 =A0None</div>
<div><br></div><div>4. Functions</div><div><br></div><div>=A0 =A04.1. json_=
path_get(json_string, json_path, destination)</div><div>=A0 =A04.2. json_ar=
ray_size(json_string, json_path, destination)</div><div>=A0 =A04.3. json_ge=
t_field(json_string, field_name, destination)</div>


<div><br></div><div>4.1. =A0json_path_get(json_string, json_path, destinati=
on)</div><div><br></div><div>=A0 =A0Copy the value at the path from json ob=
ject &#39;json_string&#39; and store it</div><div>=A0 =A0in pvar &#39;desti=
nation&#39;.</div>


<div><br></div><div>=A0 =A0The path string supports dot delimited notation =
(e.g. foo.bar.baz),</div><div>=A0 =A0array notation (e.g. list[0]), or a co=
mbination of the two (e.g.</div><div>=A0 =A0foo.bar[0][1].baz).</div><div><=
br></div>


<div>=A0 =A0The function can put a string, integer, null, or new json strin=
g into</div><div>=A0 =A0destination.</div><div><br></div><div>=A0 =A0Exampl=
e 1.1. json_path_get usage</div><div>...</div><div>json_path_get($var(myjso=
n), &quot;inner.deep.num&quot;, &quot;$var(n)&quot;);</div>


<div>xlog(&quot;foo is $var(n)&quot;);</div><div>...</div><div><br></div><d=
iv>4.2. =A0json_array_size(json_string, json_path, destination)</div><div><=
br></div><div>=A0 =A0Puts size of the array in &#39;json_string&#39; at &#3=
9;json_path&#39; into the pvar</div>


<div>=A0 =A0&#39;destination&#39;.</div><div><br></div><div>=A0 =A0This is =
particularly useful for looping through an array. See example.</div><div><b=
r></div><div>=A0 =A0Example 1.2. json_array_size usage</div><div>...</div><=
div>$var(array) =3D &quot;{\&quot;loopme\&quot;:[0,1,2,3,4,5]}&quot;;</div>


<div>$var(count) =3D 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>=A0 =A0 json_path_get($var(array), &quot;loopme[$var(count)]=
&quot;, &quot;$var(v)&quot;);</div>


<div>=A0 =A0 xlog(&quot;loopme[$var(count)] =3D=3D $var(v)\n&quot;);</div><=
div>=A0 =A0 $var(count) =3D $var(count) + 1;</div><div>}</div><div>...</div=
><div><br></div><div>4.3. =A0json_get_field(json_string, field_name, destin=
ation)</div>


<div><br></div><div>=A0 =A0Copy field &#39;field_name&#39; from json object=
 &#39;json_string&#39; and store it in</div><div>=A0 =A0pvar &#39;destinati=
on&#39;.</div><div><br></div><div>=A0 =A0This function is deprecated but ke=
pt for backwards compatibility. Right</div>


<div>=A0 =A0now it is just a wrapper around json_path_get, and its function=
ality is</div><div>=A0 =A0the same.</div><div><br></div><div>=A0 =A0Example=
 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>
<br>_______________________________________________<br>
sr-dev mailing list<br>
<a href=3D"mailto:sr-dev at lists.sip-router.org">sr-dev at lists.sip-router.org<=
/a><br>
<a href=3D"http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" tar=
get=3D"_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev<=
/a><br>
<br></blockquote></div><br>

--20cf3071ceceef3d7c04d4350d3d--



More information about the sr-dev mailing list