mathiasbynens / jsesc

Given some data, jsesc returns the shortest possible stringified & ASCII-safe representation of that data.
https://mths.be/jsesc
MIT License
716 stars 53 forks source link

Document or remove differences between `jsesc(data, { json: true })` and `JSON.stringify(data)` #17

Open mathiasbynens opened 10 years ago

mathiasbynens commented 10 years ago

For example, jsesc doesn’t skip undefined properties, and it doesn’t make use of toJSON:

var obj = {
  'toJSON': function() {
    return 'wat';
  }
};

var x = {
  'lol': obj
};

console.log([
  JSON.stringify(x),
  jsesc(x, { 'json': true })
]);
mathiasbynens commented 10 years ago

jsesc still doesn’t skip undefined properties.