mirror of
https://github.com/taigrr/yq
synced 2025-01-18 04:53:17 -08:00
explode when outputting to json
This commit is contained in:
@@ -52,6 +52,13 @@ func New() *cobra.Command {
|
||||
return err
|
||||
}
|
||||
|
||||
if outputToJSON {
|
||||
explodeOp := treeops.Operation{OperationType: treeops.Explode}
|
||||
explodeNode := treeops.PathTreeNode{Operation: &explodeOp}
|
||||
pipeOp := treeops.Operation{OperationType: treeops.Pipe}
|
||||
pathNode = &treeops.PathTreeNode{Operation: &pipeOp, Lhs: pathNode, Rhs: &explodeNode}
|
||||
}
|
||||
|
||||
matchingNodes, err := evaluate("-", pathNode)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -136,14 +136,6 @@ func printResults(matchingNodes *list.List, writer io.Writer) error {
|
||||
colorsEnabled = true
|
||||
}
|
||||
|
||||
//always explode anchors when printing json
|
||||
if explodeAnchors || outputToJSON {
|
||||
errorExploding := explode(matchingNodes)
|
||||
if errorExploding != nil {
|
||||
return errorExploding
|
||||
}
|
||||
}
|
||||
|
||||
bufferedWriter := bufio.NewWriter(writer)
|
||||
defer safelyFlush(bufferedWriter)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user