Skip to main content
3 of 3
Mostly markup changes.
Kusalananda
  • 355.9k
  • 42
  • 735
  • 1.1k

Convert value into nested key-value object, with jq

I am lost with an easy-looking jq problem. Given a key-value object, I want to transform the value into a nested object with a value-key. I tried permutations with to_entries and native output as well as the {}-output option, but without success. I'm convinced there is a rather obvious solution, but I cannot find it.

Input:

{ "mykey" : "myvalue" }

Desired output:

{ "mykey" : { "value" : "myvalue" }}