[infinispan-issues] [JBoss JIRA] (ISPN-9441) Support script execution returning JSON objects

Galder Zamarreño (JIRA) issues at jboss.org
Tue Aug 21 03:49:00 EDT 2018


    [ https://issues.jboss.org/browse/ISPN-9441?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13621837#comment-13621837 ] 

Galder Zamarreño commented on ISPN-9441:
----------------------------------------

https://stackoverflow.com/questions/38034497/java-returning-an-object-from-scriptengine-javascript

> 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}



--
This message was sent by Atlassian JIRA
(v7.5.0#75005)



More information about the infinispan-issues mailing list