首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何从这个JSON文件中获取单词

如何从这个JSON文件中获取单词
EN

Stack Overflow用户
提问于 2019-01-11 14:58:51
回答 1查看 72关注 0票数 0

我想从这个JSON文件中获取type结果。我该怎么做呢?

代码语言:javascript
运行
复制
{
    "inputs": [{
        "title": "vault_beats",
        "global": true,
        "name": "Beats",
        "content_pack": null,
        "created_at": "2019-01-11T05:31:49.720Z",
        "type": "org.graylog.plugins.beats.Beats2Input",
        "creator_user_id": "admin",
        "attributes": {
            "recv_buffer_size": 1048576,
            "tcp_keepalive": false,
            "number_worker_threads": 1,
            "tls_client_auth_cert_file": "",
            "beats_prefix": false,
            "bind_address": "0.0.0.0",
            "tls_cert_file": "",
            "port": 5044,
            "tls_key_file": "admin",
            "tls_enable": false,
            "tls_key_password": "admin",
            "tls_client_auth": "disabled",
            "override_source": null
        },
        "static_fields": {},
        "node": null,
        "id": "5c382a45590801001d742017"
    }, {
        "title": "vault_beatsl",
        "global": true,
        "name": "GELF TCP",
        "content_pack": null,
        "created_at": "2019-01-11T05:32:05.869Z",
        "type": "org.graylog2.inputs.gelf.tcp.GELFTCPInput",
        "creator_user_id": "admin",
        "attributes": {
            "recv_buffer_size": 1048576,
            "tcp_keepalive": false,
            "use_null_delimiter": true,
            "number_worker_threads": 1,
            "tls_client_auth_cert_file": "",
            "bind_address": "0.0.0.0",
            "tls_cert_file": "",
            "decompress_size_limit": 8388608,
            "port": 12201,
            "tls_key_file": "admin",
            "tls_enable": false,
            "tls_key_password": "admin",
            "max_message_size": 2097152,
            "tls_client_auth": "disabled",
            "override_source": null
        },
        "static_fields": {},
        "node": null,
        "id": "5c382a55590801001d74202b"
    }],
    "total": 2
}

示例输出:-

代码语言:javascript
运行
复制
"type":"org.graylog.plugins.beats.Beats2Input"
"type":"org.graylog2.inputs.gelf.tcp.GELFTCPInput"
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-01-11 15:37:14

这些要求有点模糊,但当与-r命令行选项一起使用时,以下命令会产生所需的输出,并且具有简单性的优点,但您可能希望对其进行调整以满足您的确切要求:

代码语言:javascript
运行
复制
.. | objects | select(.type) | "\"type\":\"\(.type)\""
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54141729

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档