pretty should output arrays on multiple lines
opened this issue · comments
proper JQ example:
$ jq '.foxtrot[].golf' hotel.json
"india"
"juliet"
"kilo"
bad JJ example:
$ jj -n -p -i hotel.json 'foxtrot.#.golf'
["india", "juliet", "kilo"]
This is by design. JJ always returns valid json.
@tidwall I am happy with JJ returning valid JSON. I also agree that JQ should
return valid JSON - however I am in bad situation because:
- JQ returns arrays on multiple lines, but not as valid JSON
- JJ returns valid JSON, but array on single line
The program I end up going with will ideally:
- return valid JSON
- return arrays on multiple lines, either as the default or with some option
Currently it seems neither program is a complete solution.
This may sound nuts but you could:
jj -i hotel.json 'foxtrot.#.golf' | jq .[]
and ideal solution would be a single program
Update JJ and try this:
jj -l -i hotel.json 'foxtrot.#.golf'
This command:
jj -l -n -i hotel.json 'foxtrot.#.golf'
puts output on multiple lines, but is no longer valid JSON. I am happy with the
result, but I will let you decide if this is acceptable - thanks
puts output on multiple lines, but is no longer valid JSON.
Correct. It can be either multiple lines or valid json. Not both. The -l
option outputs multiple lines. Otherwise it's a valid json array.
again I am happy with current result, but it seems JJ should be able to solve
both problems. JQ can solve both this way:
$ jq '[.foxtrot[].golf]' hotel.json
[
"india",
"juliet",
"kilo"
]
Ok. I'm closing this issue now.