Hm… I'll let Sundar chime in whether we intend to support JSON.stringify on
ScriptObjectMirror objects. My first impression is that we should, but there
might be some subtle semantic issues. JSObject has isArray, so we can correctly
decide whether to serialize an object as {} or [].
Attila.
On Dec 10, 2013, at 5:52 PM, André Bargull <[email protected]> wrote:
>> Thanks, I adapted the code to use ScriptUtils.wrap() and encountered a
>> strange situation where JSON.stringify returns undefined for a valid JS
>> object. Maybe another scope problem?
>>
>> Here is a reproducer:https://gist.github.com/purplefox/7893408
>
> No, it's not a scope problem. JSON.stringify isn't able to process
> ScriptObjectMirror objects, see ll. 263-270 in NativeJSON.java [1].
>
> - André
>
> [1]
> http://hg.openjdk.java.net/nashorn/jdk8/nashorn/file/tip/src/jdk/nashorn/internal/objects/NativeJSON.java