<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hello,</p>
<p>great -- I was just reading through the jsonpath specs, because I
used to do name[index] and seemed to work...</p>
<p>Cheers,<br>
Daniel<br>
</p>
<br>
<div class="moz-cite-prefix">On 14/09/16 14:09, Jonathan Hunter
wrote:<br>
</div>
<blockquote cite="mid:DUB126-W3133CCD33C3A25538A6989BDF10@phx.gbl"
type="cite">
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:Calibri
}
--></style>
<div dir="ltr">Hi guys,
<div><br>
</div>
<div>Sorry for the noise!</div>
<div><br>
</div>
<div>This works;</div>
<div><br>
</div>
<div>jansson_get("destination[0].msisdn",</div>
<div><br>
</div>
<div>Thanks</div>
<div><br>
</div>
<div>Jon<br>
<br>
<div>
<hr id="stopSpelling">From: <a class="moz-txt-link-abbreviated" href="mailto:hunterj91@hotmail.com">hunterj91@hotmail.com</a><br>
To: <a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a><br>
Date: Wed, 14 Sep 2016 08:41:41 +0000<br>
Subject: [SR-Users] jansson_get path to access a JSON
reponse containing an array<br>
<br>
<style><!--
.ExternalClass .ecxhmmessage P {
padding:0px;
}
.ExternalClass body.ecxhmmessage {
font-size:12pt;
font-family:Calibri;
}
--></style>
<div dir="ltr">
<div><span style="font-size:12pt;">Hi guys,</span></div>
<div><br>
</div>
<div>Sorry for the question but Its not clear to me using
json_path and the jansson module how to get the contents
of a response containing an array.</div>
<div><br>
</div>
<div>Please see the returned response below that I am
getting on kamailio;</div>
<div><br>
</div>
<div><span style="font-size:12pt;">{"status":"success","destination"[{"msisdn":"4412345566","route":"Carrier1"}],"maxduration":"60","source":"447777777","message_id":"c41c1823aafb80f44620f4cdc6802c0d"}</span></div>
<div><br>
</div>
<div>I can access any of the fields
status,destination,maxduration,source,message_id fine,
however you will notice with destination it has an array
(as multiple destinations with other queries could
return more than one choice).</div>
<div><br>
</div>
<div>So currently when I do jansson_get_field("$http_rb",
"destination", "$var(mapdestination)"); I get;</div>
<div><br>
</div>
<div><br>
</div>
<div>[{"msisdn":"447107110194","route":"carrier1"}]</div>
<div><br>
</div>
<div>How do I get into the contents of the array in the
first place so I can return the msisdn value itself, and
the route?</div>
<div><br>
</div>
<div>This is not a problem if its not an array, however if
the result is contained within [] how do I indicate the
path?</div>
<div><br>
</div>
<div>I have tried destination[0], destination.msisdn with
no luck, and Im sure I am missing something so any
advice would be great.</div>
<div><br>
</div>
<div>Thanks</div>
<div><br>
</div>
<div>Jon</div>
</div>
<br>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a></div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Daniel-Constantin Mierla
<a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a> - <a class="moz-txt-link-freetext" href="http://www.kamailio.org">http://www.kamailio.org</a>
<a class="moz-txt-link-freetext" href="http://twitter.com/#!/miconda">http://twitter.com/#!/miconda</a> - <a class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
</body>
</html>