JQ中的多维数组
Multi dimensional array in JQ
有人可以帮助将输入 json 转换为我在下面指定的输出格式吗?我尝试了多种方法,但我无法成功。
我有输入:
{
"hosts": [
{
"statistics": [
{
"timestamp": {
"date": "2017-06-09",
"time": "21:40:01"
},
"cpu-load": [
{
"idle": 99.64
}
]
}
]
}
]
}
我需要输出:
{
"hosts": [
{
"statistics": [
{
"timestamp": "2017-06-09 21:40:01",
"cpu-load": [
{
"idle": 99.64
}
]
}
]
}
]
}
更新运算符 |= 应该可以解决问题。
jq '.hosts[].statistics[].timestamp |= .date + " " + .time'
有人可以帮助将输入 json 转换为我在下面指定的输出格式吗?我尝试了多种方法,但我无法成功。
我有输入:
{
"hosts": [
{
"statistics": [
{
"timestamp": {
"date": "2017-06-09",
"time": "21:40:01"
},
"cpu-load": [
{
"idle": 99.64
}
]
}
]
}
]
}
我需要输出:
{
"hosts": [
{
"statistics": [
{
"timestamp": "2017-06-09 21:40:01",
"cpu-load": [
{
"idle": 99.64
}
]
}
]
}
]
}
更新运算符 |= 应该可以解决问题。
jq '.hosts[].statistics[].timestamp |= .date + " " + .time'