[OpenSIPS-Users] For-Each Example

Kneeoh kneeoh at yahoo.com
Tue Sep 8 23:01:17 CEST 2015


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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20150908/3e97a36e/attachment.htm>


More information about the Users mailing list