]
Galder Zamarreño commented on ISPN-9441:
----------------------------------------
Support script execution returning JSON objects
-----------------------------------------------
Key: ISPN-9441
URL:
https://issues.jboss.org/browse/ISPN-9441
Project: Infinispan
Issue Type: Enhancement
Reporter: Galder Zamarreño
When the last expression in a script returns a JSON object, this is returned as String
{{[object Object]}}. E.g.
{code}
var obj = { k: 1, v: 2}
obj
{code}
This is because ScriptingEngine's eval method returns an instance of
javax.script.Bindings (as ScriptObjectMirror) which is a Map<String, Object>.
Our integration layer should detect the type of the returned object and adjust it for the
consumer.
A simple workaround is to wrap the final object around {{JSON.stringify}} call, e.g.
{code}
var obj = { k: 1, v: 2}
JSON.stringify(obj)
{code}