I have a script that runs on the NetSuite platform, on which I am sure that 99% uses the Rhino JavaScript engine. I am trying to get the same script to work locally, but there is a problem with calling JSON.stringify on a wrapped Java array. In both environments, the array is of the [object JavaArray] , but while the Java array builds correctly on NetSuite, my local Rhino context says:
org.mozilla.javascript.EvaluatorException: Java class "[Ljava.lang.String;" does not have a public instance field or method named "toJSON".
At first I thought that they added the NativeJavaArray class using the toJSON method and returned it through a custom WrapFactory , but this does not seem like there is no toJSON method on the returned object.
Is there an option I need to configure for Java arrays to work with JSON methods? I would have to get around this by adding toJSON to the NativeJavaArray subclass, as I mentioned above, but I would like to be as compatible with NetSuite as possible.
java json javascript arrays rhino
David brown
source share