I want to represent json data In Column format.md
February 1, 2020 ยท View on GitHub
Query: I want to represent json data In Column format
[
{
"status": 200,
"url": "https://url1",
"length": 20429
},
{
"status": 401,
"url": "https://url2",
"length": 30890
}
]
I have data in this json format.I want to represent it in the following way :
200 20429 https://url1
401 30890 https://url2
I am not good with jq and formatting. But I want to represent the json data in the column format. So it will be very easy to read a long list or urls and their response length and status codes. Any help is appreciated.
A:
- with jtc it's a matter of dumping each record with the requested entries order:
# 1. with order of columns sorted by labels alphabetically:
bash $ <file.json jtc -w'<$#: >v[:]' -qqT'"{}"'
20429 200 https://url1
30890 401 https://url2
bash $
# 2. with order of columns in arbitrary order:
bash $ <file.json jtc -w[:] -qqT'"{$b} {$a} {$c}"'
200 20429 https://url1
401 30890 https://url2
bash $