小编am1*_*991的帖子

使 JQ 输出一张表

我的问题是:如何以表格格式制作JQ输出,用0替换不存在的值?

因此 JQ 的输入是以下 Elastic Search JSON 响应:

{"aggregations": {
    "overall": {
        "buckets": [
            {
                "key": "2018-01-18T00:00:00.000Z-2018-01-25T19:33:16.010Z",
                "from_as_string": "2018-01-18T00:00:00.000Z",
                "to": 1516908796010,
                "to_as_string": "2018-01-25T19:33:16.010Z",
                "doc_count": 155569,
                "agg_per_name": {
                    "doc_count_error_upper_bound": 0,
                    "sum_other_doc_count": 0,
                    "buckets": [
                        {
                            "key": "ASSET-DD583",
                            "doc_count": 3016,
                            "totalMaxUptime_perDays": {
                                "buckets": [
                                    {
                                        "key_as_string": "2018-01-22T00:00:00.000Z",
                                        "key": 1516579200000,
                                        "doc_count": 161,
                                        "totalMaxUptime": {
                                            "value": 77598
                                        }
                                    },
                                    {
                                        "key_as_string": "2018-01-23T00:00:00.000Z",
                                        "key": 1516665600000,
                                        "doc_count": 251,
                                        "totalMaxUptime": {
                                            "value": 80789
                                        }
                                    },
                                    {
                                        "key_as_string": "2018-01-24T00:00:00.000Z",
                                        "key": 1516752000000,
                                        "doc_count": 192,
                                        "totalMaxUptime": {
                                            "value": 56885
                                        } …
Run Code Online (Sandbox Code Playgroud)

bash json tabular missing-data jq

3
推荐指数
2
解决办法
5297
查看次数

标签 统计

bash ×1

jq ×1

json ×1

missing-data ×1

tabular ×1