I haven't tried and I am not the developer of jansson module, but of you
control how the json doc is written in redis, then you can try to store
the value as number (not enclosed in quotes) and maybe jansson store its
value directly as int in the kamailio.cfg variable.
Otherwise, using {s.int} is the recommended way. I would just store
first in a $var(x) as string value and then move it to $avp(...)
converted to int.
If you store first to $avp(val) and then do:
$avp(val) = $(avp(val){s.int});
you end up with two $avp(val) -- AVPs work as a multi-value stack, an
assignment adds to the top of the stack. Overall, it should be fine,
this is more like a cosmetic change.
Cheers,
Daniel
On 21.05.19 09:34, Stephen Bucklin wrote:
Daniel,
Sorry, I did not see your reply as well. I struggle with mobile email! :-)
Yes, as above I used the s.int <http://s.int> but was possibly looking
at a more elegantly constructed methid when moving the value into the
avp at the start.
Steve
On Tue, 21 May 2019 at 07:50, Stephen Bucklin
<steve(a)telcoelectronics.uk <mailto:steve@telcoelectronics.uk>> wrote:
Hi,
I would like to set is an an integer. Forgive me as I am on mobile
so this is from memory. I am getting a string using REDIS
something like:
Redis_cmd("dB","GET key:xyz","r")
I now have some string in $redus(r=>value) say
{"this":"that","mum":"3","other":"here"}
I have used the jansson_get to move the value of the specific key
into an AVP for use. If I move the value 3 that is keyed by "num"
from the Jason into the AVP it is a string. I can use $avp(val) =
$(avp(val){s.int <http://s.int>}) and that will work but was
wondering if there was a more elegant solution to this?
Just finding my way around this new landscape :-)
Steve
On Mon, 20 May 2019 at 18:14, Alex Balashov
<abalashov(a)evaristesys.com <mailto:abalashov@evaristesys.com>> wrote:
You want to validate that the value is an integer, or coerce
the internal type of the AVP to integer?
—
Sent from mobile, with due apologies for brevity and errors.
On May 20, 2019, at 7:52 AM, Stephen Bucklin
<steve(a)telcoelectronics.uk <mailto:steve@telcoelectronics.uk>>
wrote:
Hi,
Any quick thoughts. I am using a REDIS "GET" to retrieve a
JSON
obj as a string from REDIS and then the JANSSON get value
to extract a key value from the string and pop it into an AVP
($avp(val)) and wish to ensure the value is an integer in the
AVP. New to this, be kind :-)
Steve
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users(a)lists.kamailio.org <mailto:sr-users@lists.kamailio.org>
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users(a)lists.kamailio.org <mailto:sr-users@lists.kamailio.org>
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
sr-users(a)lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users