[OpenSIPS-Users] acc db_extra not allowing JSON variables

Bogdan-Andrei Iancu bogdan at opensips.org
Fri Jan 25 13:15:08 CET 2013


Hi Brett,

The missing value warning is fixed on SVN.

I was also trying to fix the concat issue, but not able to reproduce it. 
I tried 2 different cases:

     $json(var1) := '{"string1":"String1data"}';
     $json(var2) := '{"string2":"String2data"}';

     $avp(result) = $json(var1/string1) + $json(var2/string2);

     xlog("result is <$avp(result)> \n");


or

     $json(var1) := '{"string1":"String1data","string2":"String2data"}';
     $json(var2) := '{"string2":"String2data"}';

     $avp(result) = $json(var1/string1) + $json(var1/string2);

     xlog("result is <$avp(result)> \n");


In both cases I got the a valid output....

Any help with it ?

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com


On 01/22/2013 02:13 PM, Bogdan-Andrei Iancu wrote:
> Hi Brett,
>
> So, some initial data:
>
> The $json variables are (as scope) the same as $var - which means they 
> have visibility only per process (as names they do exist in all procs, 
> but they have different instances / values in each proc), but inside 
> the process they are global - visible to all messages, from all routes 
> which are executed in that particular process (!so take care that to 
> reset the json before usage as you may inherit some value from a 
> previous execution in the same proc).
>
> Now, about your cases:
>
> 1) using a $json in extra_db - it is visibility issue - you set the 
> json var for INVITE (in a process) and you try to read it for the BYE 
> (in a different proc). Actually the error you get says that you try to 
> read a $json which was never set.
>
> 2) using it from failure / onreply routes - same as above.
>
>
> Which leaves us with 2 real bugs:
>
> 1) when merging 2 jsons - the bogus len - we will look into it
>
> 2) the errors on missing values or tags - I will change them to DBG 
> and to actually return NULL value to script.
>
> Thanks and regards,
> Bogdan-Andrei Iancu
> OpenSIPS Founder and Developer
> http://www.opensips-solutions.com
>
> On 01/16/2013 05:50 PM, Brett Nemeroff wrote:
>> Bogdan,
>> I'm actually getting all sorts of weird errors with the JSON module..
>> Using it in place, for simple things it works great.
>>
>> If I concatonate json variables and place them into an avp, I get 
>> junk at the end
>>
>> $avp(result) = $json(somevar/string1) + $json(somevar/string2);
>>
>> $avp(result) will be something like "String1dataString2dataM\002"
>>
>> The M\002 is random.. Almost like a variable that isn't initialized.
>>
>> Also. $json variables don't survive to onreply routes or failure 
>> routes. And they can't be used in db_extra. There also isn't a real 
>> good way to reliably check for the existence of a json element 
>> without throwing an error in the log
>>
>> Thanks for looking at this. If there is anything I can do to help, 
>> let me know.
>> -Brett
>>
>>
>> On Wed, Jan 16, 2013 at 6:58 AM, Bogdan-Andrei Iancu 
>> <bogdan at opensips.org <mailto:bogdan at opensips.org>> wrote:
>>
>>     Hi Brett,
>>
>>     Never tried something like that, but let me run some tests....
>>
>>     Regards,
>>
>>     Bogdan-Andrei Iancu
>>     OpenSIPS Founder and Developer
>>     http://www.opensips-solutions.com
>>
>>
>>     On 01/15/2013 10:29 PM, Brett Nemeroff wrote:
>>>     Anyone else run into this? Anyone using JSON??
>>>
>>>     Thanks,
>>>     Brett
>>>
>>>
>>>     On Thu, Jan 10, 2013 at 12:37 AM, Brett Nemeroff
>>>     <brett at nemeroff.com <mailto:brett at nemeroff.com>> wrote:
>>>
>>>         To make this more interesting.. I actually don't get the
>>>         $json variable in a failure route either. There definitely
>>>         seems to be something up with this variable type's scope.
>>>
>>>         For now, I save the json into a dlg_val, and restore as
>>>         needed. However, it'd be nice to let it persist. Is there a
>>>         way to do that?
>>>
>>>         Thanks,
>>>         Brett
>>>
>>>
>>>         On Wed, Jan 9, 2013 at 12:20 PM, Brett Nemeroff
>>>         <brett at nemeroff.com <mailto:brett at nemeroff.com>> wrote:
>>>
>>>             Hey All,
>>>             I'm trying to add $json variables to db_extra. I'm 100%
>>>             sure the variables are set as I'm using them all over my
>>>             script. However, when acc wants to write, I get errors
>>>             like this:
>>>
>>>
>>>             Jan  9 18:10:52 development
>>>             /usr/local/sbin/opensips[10469]: ERROR:json:pv_get_json:
>>>             Variable named:cdata1 not found
>>>
>>>             Jan  9 18:10:52 development
>>>             /usr/local/sbin/opensips[10469]: ERROR:acc:extra2strar:
>>>             failed to get 'element'
>>>
>>>
>>>             Like I said, I'm 100% sure the variable is
>>>             set: $json(cdata1/element)
>>>
>>>             It's almost like it just doesn't support $json or that
>>>             it's "out of scope"
>>>
>>>             Thanks!
>>>             -Brett
>>>
>>>
>>>
>>>
>>>     _______________________________________________
>>>     Users mailing list
>>>     Users at lists.opensips.org  <mailto:Users at lists.opensips.org>
>>>     http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>
>
> _______________________________________________
> 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/20130125/c902397c/attachment.htm>


More information about the Users mailing list