Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Unified Diff: src/json.js

Issue 3336001: Make JSON.stringify not quote non-ASCII characters. Fix bug 855. (Closed)
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/mjsunit/json.js » ('j') | test/mjsunit/json.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/json.js
diff --git a/src/json.js b/src/json.js
index e7ec6100e56f04379178e1a84f6755ad82ea019f..5dd776899b6f942d5d0e795dd373be7df924de30 100644
--- a/src/json.js
+++ b/src/json.js
@@ -68,15 +68,13 @@ function JSONParse(text, reviver) {
}
var characterQuoteCache = {
+ '\b': '\\b', // ASCII 8, Backspace
+ '\t': '\\t', // ASCII 9, Tab
+ '\n': '\\n', // ASCII 10, Newline
+ '\f': '\\f', // ASCII 12, Formfeed
+ '\r': '\\r', // ASCII 13, Carriage Return
'\"': '\\"',
- '\\': '\\\\',
- '/': '\\/',
- '\b': '\\b',
- '\f': '\\f',
- '\n': '\\n',
- '\r': '\\r',
- '\t': '\\t',
- '\x0B': '\\u000b'
+ '/': '\\/'
};
function QuoteSingleJSONCharacter(c) {
@@ -95,7 +93,7 @@ function QuoteSingleJSONCharacter(c) {
}
function QuoteJSONString(str) {
- var quotable = /[\\\"\x00-\x1f\x80-\uffff]/g;
+ var quotable = /[\\\"\x00-\x1f]/g;
return '"' + str.replace(quotable, QuoteSingleJSONCharacter) + '"';
}
« no previous file with comments | « no previous file | test/mjsunit/json.js » ('j') | test/mjsunit/json.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698