I need to use the below JSON file as input and this file could contain multiple variable entries.
I need to search var1 or var2 in environment variables and replace the value in the below JSON.
{
"var1": "valueplaceholder",
"var2": "valueplaceholder"
}
I tried the below command
cat input.json | sed "s/\"\([A-Z0-9_]*\)\":\s*\"\([A-Za-z0-9_]*\)\"/\"\1\": \"$\1\"/g"
but it creates output like
{
"var1": "$var1",
"var2": "$var2"
}
How can I get the value of variables? I.e. I need the value of $var1 instead of text $var1.
jsonand templates: Jsonnet