Skip to main content
Mostly markup changes.
Source Link
Kusalananda
  • 355.8k
  • 42
  • 735
  • 1.1k

JQ: convert Convert value into nested key-value object, with jq

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

Input:

{ "mykey" : "myvalue" }

{ "mykey" : "myvalue" }

Desired output:

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

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

JQ: convert value into nested key-value object

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 that there is a rather obvious solution, but I cannot find it.

Input:

{ "mykey" : "myvalue" }

Desired output:

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

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" }}
edited tags
Link
Jeff Schaller
  • 68.8k
  • 35
  • 122
  • 265
Source Link

JQ: convert value into nested key-value object

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 that there is a rather obvious solution, but I cannot find it.

Input:

{ "mykey" : "myvalue" }

Desired output:

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