You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Indeed, as I looked at the code, jansson_get() treats the first parameter as json-path and . is a delimiter there.
With the stable kamailio versions at this moment, up to 5.7.x, you can use json module which should work with field name, no json-path.
Alternatively, you can use the an embedded scripting language to parse the json, for example app_jsdt module is offering embedded javascript without any external dependency and inside it you can use JS function JSON.parse(), then walk through the structure and set the value of the desired field to a kamailio.cfg variable.
For the future major stable releases (or if you want to use git master branch now), I pushed some commits to jansson module to change the function jansson_get_field() to work only with the field name, leaving jansson_get() to work with json-path.
I am closing this issue as there are options for stable releases and the development branch got new code for it in the jansson module.
For the future major stable releases (or if you want to use git master branch now), I pushed some commits to jansson module to change the function jansson_get_field() to work only with the field name, leaving jansson_get() to work with json-path.
Hi,
I have sample json data as below:
$var(mapjson) = {"1.1.1.1": "cloudflare", "2.2.2.2": "ANY"};
I add this line to kamailio script but it does NOT work,
jansson_get("1.1.1.1", "$var(mapjson) ", “$var(domain)“);
or
jansson_get("1.1.1.1", "$var(mapjson) ", “$var(domain)“);
Seem kamailio thinks it is a path not a single key?
Thanks
The text was updated successfully, but these errors were encountered: