<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>I haven't developed the module, will have to look at the code,
but I would expect to work for the array object, given it relies
on libjansson external library.</p>
<p>Maybe you can try with:<br>
</p>
<font face="arial" size="2">$avp(result1)="{\"a\":[{\"origin\":\"125.16.231.74\",\"Dest\":\"725.76.731.77\"}]}";<br>
<br>
just to see if it works and there is no problem parsing that
array, but the problem is having an array as root object.<br>
<br>
Cheers,<br>
Daniel<br>
<br>
<br>
</font>
<div class="moz-cite-prefix">On 26.04.17 07:51,
<a class="moz-txt-link-abbreviated" href="mailto:vivek@advaitamtech.com">vivek@advaitamtech.com</a> wrote:<br>
</div>
<blockquote cite="mid:1493185908.584424869@apps.rackspace.com"
type="cite"><font face="arial" size="2">
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">There are no error messages
for the below test JSON object. Let me give you a clear
picture,</p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Â </p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">$avp(result1)="{\"origin\":\"125.16.231.74\",\"Dest\":\"725.76.731.77\"}"
--> Successfully parsed and result is recevied.</p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Â </p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">$avp(result1)="[{\"origin\":\"125.16.231.74\",\"Dest\":\"725.76.731.77\"}]";
--> No Error and no parsed result either.</p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Â </p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">$avp(result1)="{\"origin\":\"125.16.231.74\",\"Dest\":\"725.76.731.77\"},{\"origin\":\"225.26.231.24\",\"Dest\":\"225.26.231.27\"}";
--> Results in error. </p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Â Â ERROR: jansson
[jansson_funcs.c:59]: janssonmod_get(): failed to parse:Â
{"origin":"125.16.231.74","Dest":"725.76.731.77"},{"origin":"225.26.231.24","Dest":"225.26.231.27"}<br>
ERROR: jansson [jansson_funcs.c:61]: janssonmod_get(): json
error at line 1: end of file expected near ','</p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">$avp(result1)="[{\"origin\":\"125.16.231.74\",\"Dest\":\"725.76.731.77\"},{\"origin\":\"225.26.231.24\",\"Dest\":\"225.26.231.27\"}]"
--> No error. But no result either. GIves result as zero.</p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Â </p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">I understand that with "[ ]"
, its the right JSON object. But api doesnt give the parsed
result.</p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Â </p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Thanks,</p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Vivek.</p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Â </p>
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">-----Original Message-----<br>
From: "Daniel-Constantin Mierla" <a class="moz-txt-link-rfc2396E" href="mailto:miconda@gmail.com"><miconda@gmail.com></a><br>
Sent: Tuesday, 25 April, 2017 7:47pm<br>
To: "Kamailio (SER) - Users Mailing List"
<a class="moz-txt-link-rfc2396E" href="mailto:sr-users@lists.kamailio.org"><sr-users@lists.kamailio.org></a>,
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
Subject: Re: [SR-Users] JANSSON module not working for
multiple JSON objects<br>
<br>
</p>
<div id="SafeStyles1493184699">
<p style="margin:0;padding:0;font-family: arial; font-size:
10pt; overflow-wrap: break-word;">Hello,</p>
<br>
<div class="moz-cite-prefix">On 25.04.17 15:57, <a
moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="mailto:vivek@advaitamtech.com">vivek@advaitamtech.com</a>
wrote:</div>
<blockquote>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Hi All,</p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Â </p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Am using JANSSON module to parse the JSON
object I receive.</p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Â </p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">I tried using JSON module of kamailio. Since
its giving error in loading the module due toÂ
error"libjson-c.so.3: cannot open shared object file: No
such file or directory", I went ahead to use JANSSON
module.</p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Â </p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">JANSSON module is parsing the single JSON
object perfectly. But not parsing the multiple JSON
objects.</p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Â </p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">JSON object am trying to parse:</p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">$avp(result1)=
"[{"origin":"125.16.231.74","Dest":"725.76.731.77"},{"origin":"225.26.231.24","Dest":"225.26.231.27"}]"</p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Â </p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">JANSSON API used: jansson_get("origin",
"$avp(result1)", "$var(origin)");</p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Â </p>
<p style="margin:0;padding:0;margin: 0; padding: 0;
font-family: arial; font-size: 10pt; overflow-wrap:
break-word;">Any suggestions will be really helpful.</p>
</blockquote>
<span style="font-size: small;"><span style="font-family:
arial;">are there any error messages?<br>
<br>
Cheers,<br>
Daniel<br>
</span></span>
<p class="moz-signature" style="margin:0;padding:0;">--
Daniel-Constantin Mierla
<a moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="http://www.twitter.com/miconda">www.twitter.com/miconda</a>
-- <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - May 22-24 (USA) - <a
moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="http://www.asipto.com">www.asipto.com</a>
Kamailio World Conference - May 8-10, 2017 - <a
moz-do-not-send="true" class="moz-txt-link-abbreviated"
href="http://www.kamailioworld.com">www.kamailioworld.com</a>
</p>
</div>
</font>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - May 22-24 (USA) - <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
Kamailio World Conference - May 8-10, 2017 - <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
</body>
</html>