Java Code Examples for jdk.nashorn.api.scripting.ScriptObjectMirror#wrapAsJSONCompatible()
The following examples show how to use
jdk.nashorn.api.scripting.ScriptObjectMirror#wrapAsJSONCompatible() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NativeJava.java From TencentKona-8 with GNU General Public License v2.0 | 2 votes |
/** * Returns an object that is compatible with Java JSON libraries expectations; namely, that if it itself, or any * object transitively reachable through it is a JavaScript array, then such objects will be exposed as * {@link JSObject} that also implements the {@link List} interface for exposing the array elements. An explicit * API is required as otherwise Nashorn exposes all objects externally as {@link JSObject}s that also implement the * {@link Map} interface instead. By using this method, arrays will be exposed as {@link List}s and all other * objects as {@link Map}s. * @param self not used * @param obj the object to be exposed in a Java JSON library compatible manner. * @return a wrapper around the object that will enforce Java JSON library compatible exposure. */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object asJSONCompatible(final Object self, final Object obj) { return ScriptObjectMirror.wrapAsJSONCompatible(obj, Context.getGlobal()); }
Example 2
Source File: NativeJava.java From jdk8u60 with GNU General Public License v2.0 | 2 votes |
/** * Returns an object that is compatible with Java JSON libraries expectations; namely, that if it itself, or any * object transitively reachable through it is a JavaScript array, then such objects will be exposed as * {@link JSObject} that also implements the {@link List} interface for exposing the array elements. An explicit * API is required as otherwise Nashorn exposes all objects externally as {@link JSObject}s that also implement the * {@link Map} interface instead. By using this method, arrays will be exposed as {@link List}s and all other * objects as {@link Map}s. * @param self not used * @param obj the object to be exposed in a Java JSON library compatible manner. * @return a wrapper around the object that will enforce Java JSON library compatible exposure. */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object asJSONCompatible(final Object self, final Object obj) { return ScriptObjectMirror.wrapAsJSONCompatible(obj, Context.getGlobal()); }
Example 3
Source File: NativeJava.java From openjdk-jdk8u with GNU General Public License v2.0 | 2 votes |
/** * Returns an object that is compatible with Java JSON libraries expectations; namely, that if it itself, or any * object transitively reachable through it is a JavaScript array, then such objects will be exposed as * {@link JSObject} that also implements the {@link List} interface for exposing the array elements. An explicit * API is required as otherwise Nashorn exposes all objects externally as {@link JSObject}s that also implement the * {@link Map} interface instead. By using this method, arrays will be exposed as {@link List}s and all other * objects as {@link Map}s. * @param self not used * @param obj the object to be exposed in a Java JSON library compatible manner. * @return a wrapper around the object that will enforce Java JSON library compatible exposure. */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object asJSONCompatible(final Object self, final Object obj) { return ScriptObjectMirror.wrapAsJSONCompatible(obj, Context.getGlobal()); }
Example 4
Source File: NativeJava.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 2 votes |
/** * Returns an object that is compatible with Java JSON libraries expectations; namely, that if it itself, or any * object transitively reachable through it is a JavaScript array, then such objects will be exposed as * {@link JSObject} that also implements the {@link List} interface for exposing the array elements. An explicit * API is required as otherwise Nashorn exposes all objects externally as {@link JSObject}s that also implement the * {@link Map} interface instead. By using this method, arrays will be exposed as {@link List}s and all other * objects as {@link Map}s. * @param self not used * @param obj the object to be exposed in a Java JSON library compatible manner. * @return a wrapper around the object that will enforce Java JSON library compatible exposure. */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object asJSONCompatible(final Object self, final Object obj) { return ScriptObjectMirror.wrapAsJSONCompatible(obj, Context.getGlobal()); }
Example 5
Source File: NativeJava.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Returns an object that is compatible with Java JSON libraries expectations; namely, that if it itself, or any * object transitively reachable through it is a JavaScript array, then such objects will be exposed as * {@link JSObject} that also implements the {@link List} interface for exposing the array elements. An explicit * API is required as otherwise Nashorn exposes all objects externally as {@link JSObject}s that also implement the * {@link Map} interface instead. By using this method, arrays will be exposed as {@link List}s and all other * objects as {@link Map}s. * @param self not used * @param obj the object to be exposed in a Java JSON library compatible manner. * @return a wrapper around the object that will enforce Java JSON library compatible exposure. */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object asJSONCompatible(final Object self, final Object obj) { return ScriptObjectMirror.wrapAsJSONCompatible(obj, Context.getGlobal()); }
Example 6
Source File: NativeJava.java From hottub with GNU General Public License v2.0 | 2 votes |
/** * Returns an object that is compatible with Java JSON libraries expectations; namely, that if it itself, or any * object transitively reachable through it is a JavaScript array, then such objects will be exposed as * {@link JSObject} that also implements the {@link List} interface for exposing the array elements. An explicit * API is required as otherwise Nashorn exposes all objects externally as {@link JSObject}s that also implement the * {@link Map} interface instead. By using this method, arrays will be exposed as {@link List}s and all other * objects as {@link Map}s. * @param self not used * @param obj the object to be exposed in a Java JSON library compatible manner. * @return a wrapper around the object that will enforce Java JSON library compatible exposure. */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object asJSONCompatible(final Object self, final Object obj) { return ScriptObjectMirror.wrapAsJSONCompatible(obj, Context.getGlobal()); }
Example 7
Source File: NativeJava.java From jdk8u_nashorn with GNU General Public License v2.0 | 2 votes |
/** * Returns an object that is compatible with Java JSON libraries expectations; namely, that if it itself, or any * object transitively reachable through it is a JavaScript array, then such objects will be exposed as * {@link JSObject} that also implements the {@link List} interface for exposing the array elements. An explicit * API is required as otherwise Nashorn exposes all objects externally as {@link JSObject}s that also implement the * {@link Map} interface instead. By using this method, arrays will be exposed as {@link List}s and all other * objects as {@link Map}s. * @param self not used * @param obj the object to be exposed in a Java JSON library compatible manner. * @return a wrapper around the object that will enforce Java JSON library compatible exposure. */ @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) public static Object asJSONCompatible(final Object self, final Object obj) { return ScriptObjectMirror.wrapAsJSONCompatible(obj, Context.getGlobal()); }