我正在尝试将json转换为制表符格式的数据:
{"level":"INFO", "logger":"db", "msg":"connection successful"}
{"level":"INFO", "logger":"server", "msg":"server started"}
{"level":"INFO", "logger":"server", "msg":"listening on port :4000"}
{"level":"INFO", "logger":"server", "msg":"stopping s ervices ..."}
{"level":"INFO", "logger":"server", "msg":"exiting..."}
像这样:
INFO db connection successful
INFO server server started
INFO server listening on port 4000
DEBUG server stopping s ervices ...
INFO server exiting...
我已经尝试过jq -r ' . | to_entries[] | "\(.value)"'
,但这会在单独的行上打印每个值。
答案 0 :(得分:1)
假设键总是相同的顺序,那么您可以摆脱:
jq -r '[.[]]|@tsv'
无论如何,最好使用@tsv
。