[OpenSIPS-Users] Using $var() over $json() when casting restclient response

Tito Cumpen tito at xsvoce.com
Wed Jun 17 01:18:30 CEST 2015


Group,


Is there a downside to casting responses from a rest response into a json
object rather than a generic $var? Here is my function it works but I want
to be aware if this will cost a considerable amount of resources.

                      if (!rest_get("http://myauthurl.com/authme/$fU/$rU",
"$json(authresponse)", "$var(ct)", "$var(rcode)")) {


        xlog("Error code $var(rcode) in HTTP GET!\n");

xlog("on account of admittance error we are sending the call to the AS
server for processing");

        route(4);

}


                xlog("got this body response from authority on invite
$json(authresponse) with response code $var(rcode)");

        xlog("response now casting to json  $json(authresponse) ");

        $json(authbody) := "{}";


        $json(authbody) := $json(authresponse);

        xlog(" accessing the message $json(authbody/message)");


        $json(accept) :=  $json(authbody/message);

        xlog(" casted message $json(accept)");

        if($json(accept/AcceptCall) == "false"){

        xlog("response equal false");

                                                                route(3);



        }else{



Notice how the response is casted from $json(authresponse) to  $json(authbody)
after it is initialized. I came to realize that I had to initialize a
variable because I couldn't access keys in  $json(authresponse).



Thanks,

Tito
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20150616/f884b06c/attachment.htm>


More information about the Users mailing list