Hi,

If you have an AVP holding multiple value (instances), you can iterate through all of them as:

$var(n) = 0;
while ( $(avp(my_avp)[$var(n)]) != NULL ) {
xlog("value of my avp on position $var(n) is $(avp(my_avp)[$var(n)]) \n");
    $var(n) = $var(n) + 1 ;
}

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 09.09.2015 00:01, Kneeoh wrote:
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.

# 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");



_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

Reply via email to