joyent/node — Issue #1847: JSON.parse reviver does not work as specified
Author: hdf
Created: 2011-10-09 08:24:12+00:00
State: open

If I do this:

```
JSON.parse('{"foo":"bar"}', reviver);

function reviver (key, value) {
console.log(value);
return value;
}
```

In node.js I get this logged to console:

```
{
foo: "bar"
}
```

but in browsers I get this:

```
bar
```

as I should, based on specifications here:
http://www.json.org/js.html
and here:
http://msdn.microsoft.com/en-us/library/cc836466%28v=vs.85%29.aspx

So basically node.js does not iterate trough the json object, just passes the whole thing as value, and nothing as key.

The only reference to reviver I could find in node.js source is here:
https://github.com/joyent/node/blob/master/deps/v8/src/json.js
So it's actually a v8 thing, and it seems to be ok. But than why does it work properly in chrome, but not in node.js?