Please disregard. Found the relevant issues in Jira. JDK9: https://bugs.openjdk.java.net/browse/JDK-8149334 JDK8: https://bugs.openjdk.java.net/browse/JDK-8149443
On Wed, Mar 30, 2016 at 4:34 PM, Jay Oster <j...@pubnub.com> wrote: > Just a bug report, here. I'll let the jjs session speak for itself. > > $ jjs -version > nashorn 1.8.0_77 > jjs> var a = JSON.parse("[]") > jjs> a.length > 0 > jjs> JSON.stringify(a) > [] > jjs> a.push("foo") > 1 > jjs> a.length > 2 > jjs> JSON.stringify(a) > [0,"foo"] > > > For the moment, I have a workaround that replaces JSON.parse() with a > function that recursively replaces empty arrays with array literals. Since > they don't exhibit the same bad behavior: > > jjs> var b = [] > jjs> b.length > 0 > jjs> JSON.stringify(b) > [] > jjs> b.push("foo") > 1 > jjs> b.length > 1 > jjs> JSON.stringify(b) > ["foo"] > > >