| 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 20 matching lines...) Expand all Loading... |
| 31 var val = holder[name]; | 31 var val = holder[name]; |
| 32 if (IS_OBJECT(val)) { | 32 if (IS_OBJECT(val)) { |
| 33 if (IS_ARRAY(val)) { | 33 if (IS_ARRAY(val)) { |
| 34 var length = val.length; | 34 var length = val.length; |
| 35 for (var i = 0; i < length; i++) { | 35 for (var i = 0; i < length; i++) { |
| 36 var newElement = Revive(val, $String(i), reviver); | 36 var newElement = Revive(val, $String(i), reviver); |
| 37 val[i] = newElement; | 37 val[i] = newElement; |
| 38 } | 38 } |
| 39 } else { | 39 } else { |
| 40 for (var p in val) { | 40 for (var p in val) { |
| 41 if (ObjectHasOwnProperty.call(val, p)) { | 41 if (%_CallFunction(val, p, ObjectHasOwnProperty)) { |
| 42 var newElement = Revive(val, p, reviver); | 42 var newElement = Revive(val, p, reviver); |
| 43 if (IS_UNDEFINED(newElement)) { | 43 if (IS_UNDEFINED(newElement)) { |
| 44 delete val[p]; | 44 delete val[p]; |
| 45 } else { | 45 } else { |
| 46 val[p] = newElement; | 46 val[p] = newElement; |
| 47 } | 47 } |
| 48 } | 48 } |
| 49 } | 49 } |
| 50 } | 50 } |
| 51 } | 51 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 function SerializeObject(value, replacer, stack, indent, gap) { | 94 function SerializeObject(value, replacer, stack, indent, gap) { |
| 95 if (!%PushIfAbsent(stack, value)) { | 95 if (!%PushIfAbsent(stack, value)) { |
| 96 throw MakeTypeError('circular_structure', []); | 96 throw MakeTypeError('circular_structure', []); |
| 97 } | 97 } |
| 98 var stepback = indent; | 98 var stepback = indent; |
| 99 indent += gap; | 99 indent += gap; |
| 100 var partial = []; | 100 var partial = []; |
| 101 if (IS_ARRAY(replacer)) { | 101 if (IS_ARRAY(replacer)) { |
| 102 var length = replacer.length; | 102 var length = replacer.length; |
| 103 for (var i = 0; i < length; i++) { | 103 for (var i = 0; i < length; i++) { |
| 104 if (ObjectHasOwnProperty.call(replacer, i)) { | 104 if (%_CallFunction(replacer, i, ObjectHasOwnProperty)) { |
| 105 var p = replacer[i]; | 105 var p = replacer[i]; |
| 106 var strP = JSONSerialize(p, value, replacer, stack, indent, gap); | 106 var strP = JSONSerialize(p, value, replacer, stack, indent, gap); |
| 107 if (!IS_UNDEFINED(strP)) { | 107 if (!IS_UNDEFINED(strP)) { |
| 108 var member = %QuoteJSONString(p) + ":"; | 108 var member = %QuoteJSONString(p) + ":"; |
| 109 if (gap != "") member += " "; | 109 if (gap != "") member += " "; |
| 110 member += strP; | 110 member += strP; |
| 111 partial.push(member); | 111 partial.push(member); |
| 112 } | 112 } |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 } else { | 115 } else { |
| 116 for (var p in value) { | 116 for (var p in value) { |
| 117 if (ObjectHasOwnProperty.call(value, p)) { | 117 if (%_CallFunction(value, p, ObjectHasOwnProperty)) { |
| 118 var strP = JSONSerialize(p, value, replacer, stack, indent, gap); | 118 var strP = JSONSerialize(p, value, replacer, stack, indent, gap); |
| 119 if (!IS_UNDEFINED(strP)) { | 119 if (!IS_UNDEFINED(strP)) { |
| 120 var member = %QuoteJSONString(p) + ":"; | 120 var member = %QuoteJSONString(p) + ":"; |
| 121 if (gap != "") member += " "; | 121 if (gap != "") member += " "; |
| 122 member += strP; | 122 member += strP; |
| 123 partial.push(member); | 123 partial.push(member); |
| 124 } | 124 } |
| 125 } | 125 } |
| 126 } | 126 } |
| 127 } | 127 } |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 } | 333 } |
| 334 | 334 |
| 335 function SetupJSON() { | 335 function SetupJSON() { |
| 336 InstallFunctions($JSON, DONT_ENUM, $Array( | 336 InstallFunctions($JSON, DONT_ENUM, $Array( |
| 337 "parse", JSONParse, | 337 "parse", JSONParse, |
| 338 "stringify", JSONStringify | 338 "stringify", JSONStringify |
| 339 )); | 339 )); |
| 340 } | 340 } |
| 341 | 341 |
| 342 SetupJSON(); | 342 SetupJSON(); |
| OLD | NEW |