-1

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
  • 71,145
  • 9
  • 121
  • 139
Sandesh34
  • 269
  • 1
  • 2
  • 13

1 Answers1

2

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
  • 71,145
  • 9
  • 121
  • 139
Mani
  • 626
  • 4
  • 9