0

I'm trying to create a json file using a variable somewhat like this:

input:

ss="mango"
jq -n '{"name": {"S": $ID}}' --arg ID 'partridge in a $ss tree'

actual output:

{
  "name": {
    "S": "partridge in a $ss tree"
  }
}

expected output:

{
  "name": {
    "S": "partridge in a mango tree"
  }
}

Is there a way to achieve this using jq?

Inian
  • 80,270
  • 14
  • 142
  • 161
Sandesh34
  • 279
  • 1
  • 2
  • 14

1 Answers1

3

Try --arg ID "value" in double quote like following:

ss="mango"
jq -n '{"name": {"S": $ID}}' --arg ID "partridge in a $ss tree"

output:

{
  "name": {
    "S": "partridge in a mango tree"
  }
}
Inian
  • 80,270
  • 14
  • 142
  • 161
Mani
  • 696
  • 6
  • 12