Daniel,
Thanks, you're a star! I dug into the old stuff that was inserting the
values in REDIS, and *yes* there it was. The database was set as INT,
however the php (7) json_encode was encoding all values as a string.
There is a flag for that function called "JSON_NUMERIC_CHECK" that now
forces the INT values where needed and the object now is passed as an
INT, and then by the jansson_get() function to the avp.
Should have thought about that one. Thanks again :-)
Steve
On 21/05/2019 09:19, Daniel-Constantin Mierla wrote:
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
<[email protected] <mailto:[email protected]>> 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
<[email protected] <mailto:[email protected]>> 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
<[email protected]
<mailto:[email protected]>> 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
> [email protected]
<mailto:[email protected]>
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
[email protected] <mailto:[email protected]>
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
Kamailio (SER) - Users Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
--
Daniel-Constantin Mierla --www.asipto.com
www.twitter.com/miconda --www.linkedin.com/in/miconda
_______________________________________________
Kamailio (SER) - Users Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users