Tips & tricks for installing and running IBM products

JSON.stringify in ISAM

Tom Bosmans  30 October 2020 14:32:19
When using JSON.stringify, I get a lot these errors:

Caused by: org.mozilla.javascript.EvaluatorException: Access to Java class "java.lang.reflect.Constructor" is prohibite

This was driving me crazy, because it seemed to be very random.

Now thinking about it a bit more, it occured to me that the reason for this is that JSON.stringify needs to operate on a javascript object.
You don't always have a String object , though.  So if you try to do that on a string literal, it throws the error above.

Sometimes you can resolve this by first using JSON.parse, but that does not always work either.

The solution is simple:  just add an explicit cast to String to your string literal :

No Comments Found