What I get from jq is:
{
"frameGrid": {
"size": [
24,
24
],
"dimensions": [
1,
1
],
"names": [
[
"default"
]
]
}
}
What I would like to see is something more like this:
{
"frameGrid": {
"size": [24,24],
"dimensions": [1,1],
"names": [["default"]]
}
}
I know both forms are valid, and that jq has a compact/pretty print mode. But is there something in-between? I'm looking to somehow format a larger json file that has many more array values than this, so that it's easily readable and printable. Maybe I'm just using the wrong tool for this job?
(please excuse the horrid formating choice. Seems code-sample doesn't like json formats much)
While it is probably best to use a tool like the one peak suggested if your json isn't too complex you could use a second jq invocation to postprocess the output of the first. For example if your data is in data.json
$ jq -M . data.json | jq -MRsr 'gsub("\n +";"")|gsub("\n ]";"]")'
produces
{
"frameGrid": {
"size": [24,24],
"dimensions": [1,1],
"names": [["default"]]
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With