Skip to content

Instantly share code, notes, and snippets.

@weisjohn
Created May 15, 2014 14:36
Show Gist options
  • Save weisjohn/dbfee6139411738f2036 to your computer and use it in GitHub Desktop.
Save weisjohn/dbfee6139411738f2036 to your computer and use it in GitHub Desktop.
PhantomJS JSON.parse() fails on array
$ phantomjs
phantomjs> a = '[{"foo":"bar"},{"foo":"cat"}]'
"[{\"foo\":\"bar\"},{\"foo\":\"cat\"}]"
phantomjs> JSON.parse(a)
{
"0": {
"foo": "bar"
},
"1": {
"foo": "cat"
}
}
$ node
> a = '[{"foo":"bar"},{"foo":"cat"}]'
'[{"foo":"bar"},{"foo":"cat"}]'
> JSON.parse(a)
[ { foo: 'bar' }, { foo: 'cat' } ]
>
(^C again to quit)
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment