- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 03:23 AM
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?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 07:38 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 03:33 AM
Hello Jareth,
JSON.stringify does work in scoped applications. I tested this in both an application scope and global (in Scripts - Background):
var ddd = {
"test": "value"
};
gs.info(global.JSON.stringify(ddd));
Are you to post the JSON you're trying to stringify?
Thanks,
Cameron
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 03:56 AM
Thank you for your response, I seem to be having a specific issue with numeric keys...
As an example the following fails:
var objectTest = {}
objectTest["1"] = 'hello';
gs.info(global.JSON.stringify(objectTest));
It seems that numeric indexes - Even if they are enclosed within a string are still treated as numeric?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 03:59 AM
Are you running on Geneva or Helsinki? I want to ensure I'm running on the same release.
I've run this locally and it works as expected. My output:
sn_sc: {"1":"hello"}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 04:45 AM
I have tried on both Geneva and Helsinki with the same result.. can you try running in a scope other than 'global'? This seems to work in global but not within a scoped app..