'Select keys within an array then write that out to a config file as an array

I'm trying to wrap my head around the following. I'd like to place the output below into an array that I can save as a list of thermostats (which I currently only have 1, but I'd like to plan on the ability to have 2)

jq '.thermostatList[] | {name, identifier}' test.json
{
  "name": "Thermostat",
  "identifier": "123456789"
}

What I'd like

cat ~/etc/ecobee.thermostats
{
   "thermostats": [
      {
         "name": "Thermostat",
         "identifier": 123456789
      }
   ]
}

Is this possible with jq?

Thanks

jq


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source