2017-08-10 3 views
0

Entrée:comment convertir plusieurs objets json en un seul objet en utilisant 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" 
    } 
} 

sortie doit être:

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

} 

Répondre

1

Vous recherchez la fonction add:

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

devrait faire l'affaire.