<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px">Thanks Bogdan, that did the trick.<br><div id="yui_3_16_0_1_1441745859384_10606"><span></span></div> <br><div class="qtdSeparateBR"><br><br></div><div style="display: block;" class="yahoo_quoted"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"> <font face="Arial" size="2"> On Wednesday, September 9, 2015 6:14 AM, Bogdan-Andrei Iancu <bogdan@opensips.org> wrote:<br> </font> </div> <br><br> <div class="y_msg_container"><div id="yiv3517741106"><div>
<tt>Hi,<br clear="none">
<br clear="none">
If you have an AVP holding multiple value (instances), you can
iterate through all of them as:<br clear="none">
<br clear="none">
$var(n) = 0;<br clear="none">
while ( $(avp(my_avp)[$var(n)]) != NULL ) {<br clear="none">
xlog("value of my avp on position $var(n) is </tt><tt><tt>$(avp(my_avp)[$var(n)])</tt>
\n");<br clear="none">
$var(n) = $var(n) + 1 ;<br clear="none">
}<br clear="none">
<br clear="none">
Regards,<br clear="none">
</tt>
<pre class="yiv3517741106moz-signature">Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
<a rel="nofollow" shape="rect" class="yiv3517741106moz-txt-link-freetext" target="_blank" href="http://www.opensips-solutions.com/">http://www.opensips-solutions.com</a></pre>
<div class="yiv3517741106yqt3114150161" id="yiv3517741106yqt07194"><div class="yiv3517741106moz-cite-prefix">On 09.09.2015 00:01, Kneeoh wrote:<br clear="none">
</div>
<blockquote type="cite">
<div style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px;">
<div id="yiv3517741106yui_3_16_0_1_1441745859384_3783">I'm trying to figure
out how to iterate through an indexed $avp that holds json
query results. The docs are kind of spotty. Can someone share
a working snippet of code that iterates through an $avp ? This
one isn't quite working for me. First off it says only $var
and $avp can be iterated, but this example has a $json var.<br clear="none">
</div>
<div id="yiv3517741106yui_3_16_0_1_1441745859384_3782"><br clear="none">
</div>
<pre class="yiv3517741106" id="yiv3517741106yui_3_16_0_1_1441745859384_3769" style="font-size:0.9em;font-family:'Lucida Console', 'Andale Mono', 'Courier New', Courier;margin-top:0px;margin-bottom:0px;padding:6px;border:1px solid rgb(235, 235, 235);color:rgb(102, 102, 102);font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:21.5933px;text-indent:0px;text-transform:none;widows:1;word-spacing:0px;background-color:rgb(251, 254, 250);"># iterate through all JSON documents returned by a MongoDB query
cache_raw_query("mongodb:location", "{... find ...}", "$avp(res)");
for ($json(contact) in $(avp(res)[*]))
xlog("Found: $json(contact/phone) $json(contact/email)\n");
</pre>
<div id="yiv3517741106yui_3_16_0_1_1441745859384_3629"><br clear="none">
</div>
</div>
<br clear="none">
<fieldset class="yiv3517741106mimeAttachmentHeader"></fieldset>
<br clear="none">
<pre>_______________________________________________
Users mailing list
<a rel="nofollow" shape="rect" class="yiv3517741106moz-txt-link-abbreviated" ymailto="mailto:Users@lists.opensips.org" target="_blank" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a rel="nofollow" shape="rect" class="yiv3517741106moz-txt-link-freetext" target="_blank" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote></div>
<br clear="none">
</div></div><br><br></div> </div> </div> </div></div></body></html>