Closed wlnirvana closed 4 years ago
I have something similar to the following, where invokeFunction returns an object myDataObject here) internally of the type PolyglotMap, but can only be typed statically as Object. I'm wondering how the data can be extracted out.
invokeFunction
myDataObject
PolyglotMap
Object
ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("graal.js"); URL url = Foobar.class.getClassLoader().getResource("foobar.js"); engine.eval(Files.newBufferedReader(Paths.get(url.toURI()), StandardCharsets.UTF_8)); Invocable inv = (Invocable) engine; var myDataObject = (inv.invokeFunction("main", "testing data"));
Hi,
PolyglotMap implements java.util.Map so that's how you can access it.
java.util.Map
Best, Christian
I have something similar to the following, where
invokeFunction
returns an objectmyDataObject
here) internally of the typePolyglotMap
, but can only be typed statically asObject
. I'm wondering how the data can be extracted out.