oracle / graaljs

A high-performance, ECMAScript compliant, and embeddable JavaScript runtime for Java
https://www.graalvm.org/javascript/
Universal Permissive License v1.0
1.78k stars 189 forks source link

[interop] Hash support for `JSON.stringify()`? #478

Open fniephaus opened 3 years ago

fniephaus commented 3 years ago

While JSON.stringify() supports interop array elements, it does not take hash elements into consideration. Here's a simple example using Python dicts:

$ polyglot --jvm --shell
GraalVM MultiLanguage Shell 21.1.0
Copyright (c) 2013-2020, Oracle and/or its affiliates
  JavaScript version 21.1.0
  Python version 3.8.5
  Squeak/Smalltalk version 21.2.0-dev
js> JSON.stringify(Polyglot.eval('python', '[1, 2, 3, 4]'))
[1,2,3,4] // -> expected result
js> JSON.stringify(Polyglot.eval('python', '{"result": [1, 2, 3, 4]}'))
{} // -> unexpected result, should be `{"results": [1,2,3,4]}`
munishchouhan commented 3 years ago

@fniephaus thanks for reporting the issue, we will check it out and get back to you

munishchouhan commented 3 years ago

@fniephaus I have raised this issue with our dev team