如何使用jq将多个json对象转换为一个对象?

时间:2017-08-10 09:26:04

标签: jq

输入:

{
  "ip": {
    "ip_ip_dst": "4.2.2.2",
    "ip_ip_src": "192.168.2.208"
  },
  "dns": {
    "text_dns_qry_class": "0x00000001",
    "text_dns_a": "104.199.136.182",
    "text_dns_qry_name_len": "15",
    "text_dns_qry_name": "vehere.odoo.com",
    "text_dns_resp_type": "1",
    "text_dns_qry_type": "1"
  },
  "frame": {
    "frame_frame_len": "79",
    "frame_frame_time": "Aug 9, 2017 13:21:29.987979869 IST"
  }
}

输出应为:

{
    "ip_ip_dst": "4.2.2.2",
    "ip_ip_src": "192.168.2.208"
    "text_dns_qry_class": "0x00000001",
    "text_dns_a": "104.199.136.182",
    "text_dns_qry_name_len": "15",
    "text_dns_qry_name": "vehere.odoo.com",
    "text_dns_resp_type": "1",
    "text_dns_qry_type": "1"
    "frame_frame_len": "79",
    "frame_frame_time": "Aug 9, 2017 13:21:29.987979869 IST"

}

1 个答案:

答案 0 :(得分:1)

您正在寻找add功能:

jq 'add' file.json