Skip to content

Commit

Permalink
Merge pull request #135 from jordanbtucker/stringify-empty-array
Browse files Browse the repository at this point in the history
Do not add indent when stringifying empty arrays
  • Loading branch information
jordanbtucker committed Nov 27, 2016
2 parents 34674b8 + f5d7393 commit 007d6a1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/json5.js
Expand Up @@ -724,7 +724,10 @@ JSON5.stringify = function (obj, replacer, space) {
}
}
objStack.pop();
buffer += makeIndent(indentStr, objStack.length, true) + "]";
if (obj_part.length) {
buffer += makeIndent(indentStr, objStack.length, true)
}
buffer += "]";
} else {
checkForCircular(obj_part);
buffer = "{";
Expand Down
1 change: 1 addition & 0 deletions test/stringify.js
Expand Up @@ -50,6 +50,7 @@ exports.stringify.oddities = function test() {
};

exports.stringify.arrays = function test() {
assertStringify([]);
assertStringify([""]);
assertStringify([1, 2]);
assertStringify([undefined]);
Expand Down

0 comments on commit 007d6a1

Please sign in to comment.