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

Side by Side Diff: src/json.js

Issue 1220603002: Fix the reviver function in JSON.parse Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « AUTHORS ('k') | test/mjsunit/regress/regress-3136.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var $jsonSerializeAdapter; 5 var $jsonSerializeAdapter;
6 6
7 (function(global, utils) { 7 (function(global, utils) {
8 8
9 "use strict"; 9 "use strict";
10 10
(...skipping 17 matching lines...) Expand all
28 28
29 // ------------------------------------------------------------------- 29 // -------------------------------------------------------------------
30 30
31 function Revive(holder, name, reviver) { 31 function Revive(holder, name, reviver) {
32 var val = holder[name]; 32 var val = holder[name];
33 if (IS_OBJECT(val)) { 33 if (IS_OBJECT(val)) {
34 if (IS_ARRAY(val)) { 34 if (IS_ARRAY(val)) {
35 var length = val.length; 35 var length = val.length;
36 for (var i = 0; i < length; i++) { 36 for (var i = 0; i < length; i++) {
37 var newElement = Revive(val, %_NumberToString(i), reviver); 37 var newElement = Revive(val, %_NumberToString(i), reviver);
38 val[i] = newElement; 38 if (IS_UNDEFINED(newElement)) {
39 delete val[i];
40 } else {
41 val[i] = newElement;
42 }
39 } 43 }
40 } else { 44 } else {
41 for (var p in val) { 45 for (var p in val) {
42 if (HAS_OWN_PROPERTY(val, p)) { 46 if (HAS_OWN_PROPERTY(val, p)) {
43 var newElement = Revive(val, p, reviver); 47 var newElement = Revive(val, p, reviver);
44 if (IS_UNDEFINED(newElement)) { 48 if (IS_UNDEFINED(newElement)) {
45 delete val[p]; 49 delete val[p];
46 } else { 50 } else {
47 val[p] = newElement; 51 val[p] = newElement;
48 } 52 }
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 // JSON Builtins 249 // JSON Builtins
246 250
247 $jsonSerializeAdapter = function(key, object) { 251 $jsonSerializeAdapter = function(key, object) {
248 var holder = {}; 252 var holder = {};
249 holder[key] = object; 253 holder[key] = object;
250 // No need to pass the actual holder since there is no replacer function. 254 // No need to pass the actual holder since there is no replacer function.
251 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); 255 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", "");
252 } 256 }
253 257
254 }) 258 })
OLDNEW
« no previous file with comments | « AUTHORS ('k') | test/mjsunit/regress/regress-3136.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698