Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Error using using global.JSON.stringify() in scoped application - 'Evaluator.evaluateString() problem: java.lang.ClassCastException:'

jarethdisley
Kilo Contributor

I am getting this error 'Evaluator.evaluateString() problem: java.lang.ClassCastException:' when using global.JSON.stringify() in a scoped application - Any ideas why?

In my opinion JSON.stringify should work for any valid Javascript object - Is this not the case?

1 ACCEPTED SOLUTION

I tried it on Helsinki with no issues. Helsinki uses ECMAScript5 by default and may be more resilient to this sort of thing. If you have upgraded to Helsinki, your app is likely still using ES3. You can change it on the app settings.



I tried your simple script in Geneva and it kept failing with a numeric object property name (1). As soon as I changed it to 'a', it worked fine. That's what leads me to believe this is an ES3 vs ES5 thing.


View solution in original post

11 REPLIES 11

Hi Jareth,



You're correct, the problem is the integer you're trying to use as the key for your object. I can recreate this using a Geneva and Helsinki.



A simple solution would be to prefix it with some constant to get around this.



Thanks,



Cameron


Thanks for your assistance with this, I will have to use a prefix for now but still think this is an underlying issue with either the platform of Rhino - I will try and get this raised as a defect!


Runs fine for me in a scope. I just ran it from Scripts Background, selected one of my scoped apps and got this for the output.



x_66238_mars: {"1":"hello"}


Hey Chuck



What release is your instance running on?


I tried it on Helsinki with no issues. Helsinki uses ECMAScript5 by default and may be more resilient to this sort of thing. If you have upgraded to Helsinki, your app is likely still using ES3. You can change it on the app settings.



I tried your simple script in Geneva and it kept failing with a numeric object property name (1). As soon as I changed it to 'a', it worked fine. That's what leads me to believe this is an ES3 vs ES5 thing.