-
Task
-
Resolution: Fixed
-
P3
-
8u60
We added a new feature to the Nashorn's built-in Java object for 8u60. This change needs to be documented, preferrably in the http://docs.oracle.com/javase/8/docs/technotes/guides/scripting/prog_guide/javascript.html document.
An added section, preferrably "3.11. Passing JSON Objects to Java" is needed with the following content:
"In the previous section we mentioned that every JavaScript object when exposed to Java APIs implements the java.util.Map interface. This is true even for JavaScript arrays. However, this behavior is often not the desired or expected one when the Java code expects JSON-parsed objects. Java libraries that manipulate JSON-parsed objects usually expect arrays to expose the java.util.List interface instead. If you need to expose your JavaScript objects in such a manner that arrays are exposed as lists and not maps, you can use the Java.asJSONCompatible(obj) function, where obj is the root of your JSON object tree."
An added section, preferrably "3.11. Passing JSON Objects to Java" is needed with the following content:
"In the previous section we mentioned that every JavaScript object when exposed to Java APIs implements the java.util.Map interface. This is true even for JavaScript arrays. However, this behavior is often not the desired or expected one when the Java code expects JSON-parsed objects. Java libraries that manipulate JSON-parsed objects usually expect arrays to expose the java.util.List interface instead. If you need to expose your JavaScript objects in such a manner that arrays are exposed as lists and not maps, you can use the Java.asJSONCompatible(obj) function, where obj is the root of your JSON object tree."