Reputation: 1385
There is a value that is used several times in a json file.
I want to make this value as a variable, and want the variable to be used instead of inserting string each time.
"DOCKER_IMAGE": "registry.somewhere.com:tag",
"components":[
{
"name": "component_1",
"docker_image": $DOCKER_IMAGE
...
},
{
"name": "component_2",
"docker_image": $DOCKER_IMAGE
...
}
Something like this.
How can I achieve this?
Upvotes: 0
Views: 4404
Reputation: 550
Short answer, you cannot do this in regular JSON. A possible workaround is to put placeholder text where you want the "variable" to be filled in, then globally replace it before decoding the JSON string.
Upvotes: 2