diff --git a/src/lib_json/json_writer.cpp b/src/lib_json/json_writer.cpp index 467ab82..d8a3046 100644 --- a/src/lib_json/json_writer.cpp +++ b/src/lib_json/json_writer.cpp @@ -376,6 +376,9 @@ bool StyledWriter::isMultineArray(const Value& value) { addChildValues_ = true; int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' for (int index = 0; index < size; ++index) { + if (hasCommentForValue(value[index])) { + isMultiLine = true; + } writeValue(value[index]); lineLength += int(childValues_[index].length()); } @@ -584,6 +587,9 @@ bool StyledStreamWriter::isMultineArray(const Value& value) { addChildValues_ = true; int lineLength = 4 + (size - 1) * 2; // '[ ' + ', '*n + ' ]' for (int index = 0; index < size; ++index) { + if (hasCommentForValue(value[index])) { + isMultiLine = true; + } writeValue(value[index]); lineLength += int(childValues_[index].length()); } diff --git a/test/data/test_comment_00.expected b/test/data/test_comment_00.expected new file mode 100644 index 0000000..284a797 --- /dev/null +++ b/test/data/test_comment_00.expected @@ -0,0 +1,4 @@ +// Comment for array +.=[] +// Comment within array +.[0]="one-element" diff --git a/test/data/test_comment_00.json b/test/data/test_comment_00.json new file mode 100644 index 0000000..4df577a --- /dev/null +++ b/test/data/test_comment_00.json @@ -0,0 +1,5 @@ +// Comment for array +[ + // Comment within array + "one-element" +]