J'ai pu transformer les données mais je n'obtiens pas le résultat souhaité.
(ce que j'ai essayé) :
[inputs | {author , totalpages : .pages , books : [{"title": .title, "year" : .year }] } ] | sort
Entrée :
{"title":"War of the worlds","author":"H G Wells","year":1896,"pages":203}
{"title":"The invisible man","author":"H G Wells","year":1895,"pages":2136}
{"title":"The Lost World","author":"A C Doyle","year":1912,"pages":185}
{"title":"A Study in Scarlet","author":"A C Doyle","year":1887,"pages":251}
{"title":"20,000 leagues under the sea","author":"J Verne","year":1870,"pages":450}
devrait l'être :
{
"author": "A C Doyle",
"totalpages": 436,
"books": [
{
"title": "The Lost World",
"year": 1912
},
{
"title": "A Study in Scarlet",
"year": 1887
}
]
}
{
"author": "H G Wells",
"totalpages": 2339,
"books": [
{
"title": "War of the worlds",
"year": 1896
},
{
"title": "The invisible man",
"year": 1895
}
]
}
{
"author": "J Verne",
"totalpages": 450,
"books": [
{
"title": "20,000 leagues under the sea",
"year": 1870
}
]
}