OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 var characterQuoteCache = { | 70 var characterQuoteCache = { |
71 '\b': '\\b', // ASCII 8, Backspace | 71 '\b': '\\b', // ASCII 8, Backspace |
72 '\t': '\\t', // ASCII 9, Tab | 72 '\t': '\\t', // ASCII 9, Tab |
73 '\n': '\\n', // ASCII 10, Newline | 73 '\n': '\\n', // ASCII 10, Newline |
74 '\f': '\\f', // ASCII 12, Formfeed | 74 '\f': '\\f', // ASCII 12, Formfeed |
75 '\r': '\\r', // ASCII 13, Carriage Return | 75 '\r': '\\r', // ASCII 13, Carriage Return |
76 '\"': '\\"', | 76 '\"': '\\"', |
77 '/': '\\/' | 77 '\\': '\\\\' |
78 }; | 78 }; |
79 | 79 |
80 function QuoteSingleJSONCharacter(c) { | 80 function QuoteSingleJSONCharacter(c) { |
81 if (c in characterQuoteCache) { | 81 if (c in characterQuoteCache) { |
82 return characterQuoteCache[c]; | 82 return characterQuoteCache[c]; |
83 } | 83 } |
84 var charCode = c.charCodeAt(0); | 84 var charCode = c.charCodeAt(0); |
85 var result; | 85 var result; |
86 if (charCode < 16) result = '\\u000'; | 86 if (charCode < 16) result = '\\u000'; |
87 else if (charCode < 256) result = '\\u00'; | 87 else if (charCode < 256) result = '\\u00'; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 } | 257 } |
258 | 258 |
259 function SetupJSON() { | 259 function SetupJSON() { |
260 InstallFunctions($JSON, DONT_ENUM, $Array( | 260 InstallFunctions($JSON, DONT_ENUM, $Array( |
261 "parse", JSONParse, | 261 "parse", JSONParse, |
262 "stringify", JSONStringify | 262 "stringify", JSONStringify |
263 )); | 263 )); |
264 } | 264 } |
265 | 265 |
266 SetupJSON(); | 266 SetupJSON(); |
OLD | NEW |