fix JSON to match native browser behavior

This commit is contained in:
Misko Hevery
2011-03-30 16:28:28 -07:00
parent f57536ddb6
commit 26e651996a
2 changed files with 6 additions and 5 deletions

View File

@@ -128,9 +128,9 @@ function toJsonArray(buf, obj, pretty, stack) {
var childPretty = pretty ? pretty + " " : false;
var keys = [];
for(var k in obj) {
if (obj[k] === undefined)
continue;
keys.push(k);
if (obj.hasOwnProperty(k) && obj[k] !== undefined) {
keys.push(k);
}
}
keys.sort();
for ( var keyIndex = 0; keyIndex < keys.length; keyIndex++) {