OLD | NEW |
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 Loading... |
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 Loading... |
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 }) |
OLD | NEW |