Reputation: 1295
We are in the process of converting apps from Lasso 8 to Lasso 9, and as an intermediate step, have upgraded from 8.5.5 to 8.6.2 (which runs alongside 9 on our new box, in different virtual hosts).
I am finding that with 8.6.2 we are getting a slew of errors on pages that call encode_json
. The weird thing with these errors is that they don't start happening until some period of time after the site starts. Then, some hours later, all encode_json
calls begin to fail with error messages like this:
An error occurred while processing your request.
Error Information
Error Message: No tag, type or constant was defined under the name "〰〲硜㉻紱硜㉻紳尭筸戵屽筸搵硜" with arguments: array: (pair: (-find)=([\x{0020}-\x{21}\x{23}-\x{5b}\x{5d}-\x{10fff}])), (r)
at: onCompare with params: 'r'
at: JSON with params: 'reload', -Options=array: (-Internal)
at: JSON with params: @map: (reload)=(false), (tcstring)=(LZU), (timestring)=(10:42 AM 1442Z)
at: [...].lasso with params: 'pageloadtime'='1383038310' on line: 31 at position: 1
Error Code: -9948
(Yes, those Chinese(?) characters are in the error message.) I have removed the 8.5.5 encode_json tag from LassoStartup, so we are using the correct built-in method. The encode_json method fails for any and all parameters I throw at it from simple strings to arrays of maps. Upon restarting the site, encode_json resumes working for an hour or two, seemingly depending on load.
On 8.5.5, we don't have this problem. Does anyone have experience with this issue? Any advice regarding trying the 8.5.5 tag swap encode_json to see if I can override the built-in method? Maybe it will work better?
Upvotes: 0
Views: 160
Reputation: 813
You can try following code which I found from internet and used it.
It is working for me.
<?LassoScript
define_tag('jsonHash', -required='input',-type='array',
-description='Takes a Lasso Array and outputs a json Hash. Lassosoft offers a complex json type but, not needed in this case.
Outputs name/value pairs.This can and should be moved to a common location with other custom tags.');
local('ret'='[');
local('this'=string);
iterate: #input, local:'x';
local:'xSize' = #x->size;
#this += '{';
iterate: #x, local:'i';
#this += '"' + #i->first + '":"' + decode_html(#i->second) + '"';
if: #xSize != loop_count;
#this += ",";
/if;
/iterate;
#this += '}';
if(#input->size != loop_count);
#this += ',';
/if;
/iterate;
#ret += #this + ']';
return(#ret);
/define_tag;
encode_json("Arguement");
?>
Hope it helps you.
Thanks
Upvotes: 0
Reputation: 1295
Upgrading to the "-3" patch of 8.6.2 from the LassoSoft Downloads seems to have solved the problem entirely.
-Justin
Upvotes: 1
Reputation: 308
It would be interesting to see if your 8.5.5 code you had in startup would work. If it's the same tag thats on TagSwap, then I would do the following:
Remove the check to see if it already exists (If: (Lasso_TagExists: 'Encode_JSON') == False;)
Add "-Priority='Replace'" to the method definition (Define_Tag: 'JSON', -Namespace='Encode_', -Priority='Replace', ....)
Note, I'm not sure if the built-in methods use namespacing like the above, or if they just use "define_tag('encode_json')". For this reason, I would recommend first trying to replace the built-in method with a one that just returns "It Works!". This will allow you to test it out and make sure you are replacing the already defined method. Once you've got the tag definition correct for replacing it, then let it do its thing.
Upvotes: 0
Reputation: 1295
Rick from LassoTalk helped with the following info:
Hi Justin,
I can't help but did recall this subject in another thread back in August - the end result of that thread appears to be a bug report.
http://lasso.2283332.n4.nabble.com/Encode-JSON-error-td4639201.html
Very best regards,
Rick
Upvotes: 1