【发布时间】:2018-02-17 09:55:58
【问题描述】:
如何将最后一列的数字四舍五入到小数点后两位?
我有 json:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 9,
"successful": 9,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 2.575364,
"hits": [
{
"_index": "my-2017-08",
"_type": "log",
"_id": "AV5V8l0oDDWj-VP3YnCw",
"_score": 2.575364,
"_source": {
"acb": {
"version": 1,
"id": "7",
"owner": "pc",
"item": {
"name": "Account Average Latency",
"short_name": "Generate",
"description": "Generate of last month"
},
"service": "gsm"
},
"@timestamp": "2017-07-31T22:00:00.000Z",
"value": 210.08691986891395
}
},
{
"_index": "my-2017-08",
"_type": "log",
"_id": "AV5V8lbE28ShqBNuBl60",
"_score": 2.575364,
"_source": {
"acb": {
"version": 1,
"id": "5",
"owner": "pc",
"item": {
"name": "Profile Average Latency",
"short_name": "Profile",
"description": "Profile average latency of last month"
},
"service": "gsm"
},
"@timestamp": "2017-07-31T22:00:00.000Z",
"value": 370.20963260148716
}
}
]
}
}
我使用JQ获取csv数据:
["Name","Description","Result"],(.hits.hits[]._source | [.acb.item.name,.acb.item.description,.value])|@csv
我看到了结果:
"Name","Description","Result"
"Account Average Latency","Generate of last month",210.08691986891395
"Profile Average Latency","Profile average latency of last month",370.20963260148716
我有 210.08691986891395 和 370.20963260148716 但我想要 210.09 和 370.21
【问题讨论】: