This one was a tricky one to craft.
map
(
with_entries(select(.key != "fields"))
+
(.fields | with_entries(.value = .value[0]))
)
Let’s break it down and explain the bits of it
-
For every item in the array…
map(...) -
Create a new object containing the values for all except the
fieldsproperty.with_entries(select(.key != "fields")) -
Combine that with…
+ -
Each of the
fieldsprojecting each of the values to the first item of each array(.fields | with_entries(.value = .value[0]))