2017-08-10 91 views
0

輸入:如何使用jq將多個json對象轉換爲一個對象?

{ 
    "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

您正在尋找add功能:

jq 'add' file.json 
0
[.[]] | add 

應該做的伎倆。