[OpenSIPS-Users] json decode and access?

Richard Revels rrevels at bandwidth.com
Thu Aug 2 20:37:18 EDT 2018


I'm using a webserver response rather than cache_fetch but this may help.

                        #we got a valid response from the web server.
convert from string to json object
                        $json(resp-obj) := $avp(router-resp);
                        if( $avp(ok_log_this) == "true" )
                                xlog("L_INFO", "the whole object returned
is $json(resp-obj) and the json route first choice is
$json(resp-obj/routes[0]/ruri) \n");

...
                                        if( $json(resp-obj/lang) )
                                        {
                                                $avp(jsonLangPref) :=
$json(resp-obj/lang);
                                                $avp(jsonStatus) :=
$json(resp-obj/status);
                                                $avp(jsonSID) :=
$json(resp-obj/sid);
                                                $avp(jsonDashAddress) :=
$json(resp-obj/caller_id);
...
and so on.




On Thu, Aug 2, 2018 at 6:44 PM J E H A N Z A I B <jehanzaib.kiani at gmail.com>
wrote:

> Hi team,
>
> I have another application storing the json encoded object in the redis
> cache.
>
> I read we can fetch using cache_fetch by passing the key. This is perfect
> but I cant find a function to decode the json I have since my other
> application is encoding the json object and putting into the redis. I need
> a function to decode it first.
>
> Second question is, after the decode the object is like
>
> Object
> (
>     [id] => 161
>     [user] => xxx
>     [xx] => xxxx
>     [xxxx] => xxxx
> )
>
> How to access user for example ?
>
> Thank you
>
>
> --
> Regards,
> Jehanzaib
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20180802/98acec13/attachment.html>


More information about the Users mailing list