-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
None
-
None
-
Verified
JSON.stringify of objects wrapped with JSAdapter gets an extra wrapper of quotes. The output of the sample program
function Foo() {
var that = this;
return new JSAdapter(Foo.prototype, {}, {
__call__: function(name) {
return that[name].call(that, arguments);
}
});
}
Foo.prototype.toJSON = function() {
return '{}';
}
var f = new Foo();
console.log(JSON.stringify(f));
should be '{}' but is '"{}"'. Whatever the toJSON function returns is wrapped with an extra pair of double-quotes. The extra wrapping is unnecessary, the output of toJSON should be returned unmodified.
function Foo() {
var that = this;
return new JSAdapter(Foo.prototype, {}, {
__call__: function(name) {
return that[name].call(that, arguments);
}
});
}
Foo.prototype.toJSON = function() {
return '{}';
}
var f = new Foo();
console.log(JSON.stringify(f));
should be '{}' but is '"{}"'. Whatever the toJSON function returns is wrapped with an extra pair of double-quotes. The extra wrapping is unnecessary, the output of toJSON should be returned unmodified.