How can I transform a JSON array returned by jq into an object with a single attribute with that list's data?

Viewed 36

Suppose that the output of a jq command is a list of objects. What would be the command to get this list as the attribute of an object? That is: transforming the output from a list into an object.

Example JSON list:

[
  {"name":"Foo"},
  {"name":"Bar"}
]

Example desired output object:

The attribute "items" has been added, and contains the list that serves as input.

{
  "items": [
    {"name":"Foo"},
    {"name":"Bar"}
  ]
}
1 Answers
Related