how can i spread an object’s properties in jq?

You can add objects together to combine their contents. If a key exists in both the left and right objects the value from the right object will remain.

echo '{"a": {"a1":1, "a2": 2}, "b": 3}' | jq '.a+{b}'
{
  "a1": 1,
  "a2": 2,
  "b": 3
}

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top