我需要使用 jq 将 JSON 字符串转换为表格格式,以便在终端中显示输出,如下所示。
{
"results": [
[
{
"field": "@timestamp",
"value": "2023-07-03 08:28:00.000"
},
{
"field": "CpuReserved",
"value": "8192.0"
},
{
"field": "CpuUtilized",
"value": "4056.412942708333"
},
{
"field": "MemoryReserved",
"value": "61440"
},
{
"field": "MemoryUtilized",
"value": "4311"
},
{
"field": "@ptr",
"value": "CpABClUKUTE0NjcxNzAzNzI0NzovYXdzL2Vjcy9jb250YWluZXJpbnNpZ2h0cy9pcmwtaW5mcmEtc2hhcmVkLWplbmtpbnMtbWFpbi9wZXJmb3JtYW5jZRABEjUaGAIGSaxosQAAAAAd+TFeAAZKKHIwAAABEiABKIDF9taRMTDA7v3WkTE4BkC9NEjNPFCBIRgAEAAYAQ=="
}
],
[
{
"field": "@timestamp",
"value": "2023-07-03 08:28:00.000"
},
{
"field": "CpuReserved",
"value": "8192.0"
},
{
"field": "CpuUtilized",
"value": "4056.412942708333"
},
{
"field": "MemoryReserved",
"value": "61440"
},
{
"field": "MemoryUtilized",
"value": "4311"
},
{
"field": "@ptr",
"value": "CpABClUKUTE0NjcxNzAzNzI0NzovYXdzL2Vjcy9jb250YWluZXJpbnNpZ2h0cy9pcmwtaW5mcmEtc2hhcmVkLWplbmtpbnMtbWFpbi9wZXJmb3JtYW5jZRABEjUaGAIGSaxosQAAAAAd+TFeAAZKKHIwAAABEiABKIDF9taRMTDA7v3WkTE4BkC9NEjNPFCBIRgAEAEYAQ=="
}
]
]
}
我想在终端中显示的内容如下:
@timestamp CpuReserved CpuUtilized MemoryReserved MemoryUtilized
==========================================================================================
2023-07-03 08:16:00.000 8192.0 410.5300065104166 61440 1417
2023-07-03 08:15:00.000 8192.0 702.310791015625 61440 792
有人可以引导我走向正确的方向吗?