mirror of
https://github.com/mikefarah/yq.git
synced 2024-11-14 07:08:06 +00:00
Dont print doc separators for JSON (https://github.com/mikefarah/yq/issues/735)
This commit is contained in:
parent
f7b50e9853
commit
3722367fbb
@ -34,7 +34,7 @@ func NewPrinter(writer io.Writer, outputToJSON bool, unwrapScalar bool, colorsEn
|
|||||||
unwrapScalar: unwrapScalar,
|
unwrapScalar: unwrapScalar,
|
||||||
colorsEnabled: colorsEnabled,
|
colorsEnabled: colorsEnabled,
|
||||||
indent: indent,
|
indent: indent,
|
||||||
printDocSeparators: printDocSeparators,
|
printDocSeparators: !outputToJSON && printDocSeparators,
|
||||||
firstTimePrinting: true,
|
firstTimePrinting: true,
|
||||||
treeNavigator: NewDataTreeNavigator(),
|
treeNavigator: NewDataTreeNavigator(),
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,9 @@ func TestPrinterMultipleDocsInSinglePrint(t *testing.T) {
|
|||||||
func TestPrinterMultipleDocsJson(t *testing.T) {
|
func TestPrinterMultipleDocsJson(t *testing.T) {
|
||||||
var output bytes.Buffer
|
var output bytes.Buffer
|
||||||
var writer = bufio.NewWriter(&output)
|
var writer = bufio.NewWriter(&output)
|
||||||
printer := NewPrinter(writer, true, true, false, 0, false)
|
// note printDocSeparators is true, it should still not print document separators
|
||||||
|
// when outputing JSON.
|
||||||
|
printer := NewPrinter(writer, true, true, false, 0, true)
|
||||||
|
|
||||||
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0)
|
inputs, err := readDocuments(strings.NewReader(multiDocSample), "sample.yml", 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user