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 48 forks source link

Add `json` option? #5

Closed mathiasbynens closed 11 years ago

mathiasbynens commented 11 years ago

This would be like JSON.stringify(string) except it would actually escape non-ASCII symbols using only the escape sequences supported by JSON.


Better (?) idea: we could just overload the stringEscape function so stringEscape(object) acts different than stringEscape(string).

mathiasbynens commented 11 years ago

There now is a json option, but it only supports strings, flat objects containing only string values, or flat arrays containing only string values. So far this has been good enough for what I need for he.