Hello,

great -- I was just reading through the jsonpath specs, because I used to do name[index] and seemed to work...

Cheers,
Daniel


On 14/09/16 14:09, Jonathan Hunter wrote:
Hi guys,

Sorry for the noise!

This works;

jansson_get("destination[0].msisdn",

Thanks

Jon


From: hunterj91@hotmail.com
To: sr-users@lists.sip-router.org
Date: Wed, 14 Sep 2016 08:41:41 +0000
Subject: [SR-Users] jansson_get path to access a JSON reponse containing an array

Hi guys,

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.

Please see the returned response below that I am getting on kamailio;

{"status":"success","destination"[{"msisdn":"4412345566","route":"Carrier1"}],"maxduration":"60","source":"447777777","message_id":"c41c1823aafb80f44620f4cdc6802c0d"}

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).

So currently when I do jansson_get_field("$http_rb", "destination", "$var(mapdestination)"); I get;


[{"msisdn":"447107110194","route":"carrier1"}]

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?

This is not a problem if its not an array, however if the result is contained within [] how do I indicate the path?

I have tried destination[0], destination.msisdn with no luck, and Im sure I am missing something so any advice would be great.

Thanks

Jon

_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://www.asipto.com - http://www.kamailio.org
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda