added case of empty object and empty array

This commit is contained in:
AJ ONeal 2013-07-28 23:09:20 -07:00
父節點 55438debc5
當前提交 1ad8b9e54f
共有 2 個檔案被更改,包括 13 行新增1 行删除

查看文件

@ -8,5 +8,7 @@
"grault": 1,
"garply": true,
"waldo": "false",
"fred": "undefined"
"fred": "undefined",
"emptyarr": [],
"emptyobj": {}
}

查看文件

@ -34,6 +34,11 @@
var output = ''
;
if (0 === x.length) {
output += '[]';
return output;
}
indentLevel = indentLevel.replace(/$/, ' ');
x.forEach(function (y) {
// TODO how should `undefined` be handled?
@ -55,6 +60,11 @@
var output = ''
;
if (0 === Object.keys(x).length) {
output += '{}';
return output;
}
indentLevel = indentLevel.replace(/$/, ' ');
Object.keys(x).forEach(function (k) {
var val = x[k]