J'ai un fichier json et je veux ajouter un nouveau tableau d'objets sur elle. Je suis en train d'utiliser jq ligne de commande. Comme je cherchais à internet cette commande est à faire, pas seulement pour les objets de requête au fichier Json. Mais je ne peux pas comprendre comment utiliser la commande AJOUTER jq. Mon fichier Json est le rapport-2017-01-07.json >>
{
"report":"1.0",
"data":{
"date":"2010-01-07",
"messages":[
{
"date":"2010-01-07T19:58:42.949Z",
"xml":"xml_samplesheet_2017_01_07_run_09.xml",
"status":"OK",
"message":"metadata loaded into iRODS successfully"
},
{
"date":"2010-01-07T20:22:46.949Z",
"xml":"xml_samplesheet_2017_01_07_run_09.xml",
"status":"NOK",
"message":"metadata duplicated into iRODS"
},
{
"date":"2010-01-07T22:11:55.949Z",
"xml":"xml_samplesheet_2017_01_07_run_09.xml",
"status":"NOK",
"message":"metadata was not validated by XSD schema"
}
]
}
}
Je suis l'aide de la commande ci-dessous > > >
$ cat report-2017-01-07.json | jq -s '.data.messages {"date": "2010-01-07T19:55:99.999Z", "xml": "xml_samplesheet_2017_01_07_run_09.xml", "status": "OKKK", "message": "metadata loaded into iRODS successfullyyyyy"}'
jq: error: syntax error, unexpected '{', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
.data.messages {"date": "2010-01-07T19:55:99.999Z", "xml": "xml_samplesheet_2017_01_07_run_09.xml", "status": "OKKK", "message": "metadata loaded into iRODS successfullyyyyy"}
jq: 1 compile error
J'ai déjà essayé une autre commandes combinaison, mais je suis toujours à la fin avec l'erreur de compilation. Toute allusion à ce sujet? Merci!
la sortie doit ressembler à >>
{
"report": "1.0",
"data": {
"date": "2010-01-07",
"messages": [{
"date": "2010-01-07T19:58:42.949Z",
"xml": "xml_samplesheet_2017_01_07_run_09.xml",
"status": "OK",
"message": "metadata loaded into iRODS successfully"
}, {
"date": "2010-01-07T20:22:46.949Z",
"xml": "xml_samplesheet_2017_01_07_run_09.xml",
"status": "NOK",
"message": "metadata duplicated into iRODS"
}, {
"date": "2010-01-07T22:11:55.949Z",
"xml": "xml_samplesheet_2017_01_07_run_09.xml",
"status": "NOK",
"message": "metadata was not validated by XSD schema"
}, {
"date": "2010-01-07T19:55:99.999Z",
"xml": "xml_samplesheet_2017_01_07_run_09.xml",
"status": "OKKKKKKK",
"message": "metadata loaded into iRODS successfullyyyyy"
}]
}
}