So I have two JSON files:
bosh.json:
{
"key_pair_name": "my-aws-keypair",
"ssh_private_key": "my-key-name",
"trusted_certificates": "my-trusted-certs"
}
model.json:
{
"trusted_certificates": "vault-supplied-value",
"vm_password_type": "generate"
}
and I want to update the model.json file with the bosh.json file so it looks like this:
{
"trusted_certificates": "my-trusted-certs",
"vm_password_type": "generate"
}
I tried this:
jq --argfile bosh bosh.json '. += $bosh' model.json
but I get too many keys
{
"trusted_certificates": "my-trusted-certs",
"vm_password_type": "generate",
"key_pair_name": "my-aws-keypair",
"ssh_private_key": "my-key-name"
}
and
jq --argfile bosh bosh.json '. + $bosh' model.json
yeilds the same...
{
"trusted_certificates": "my-trusted-certs",
"vm_password_type": "generate",
"key_pair_name": "my-aws-keypair",
"ssh_private_key": "my-key-name"
}
while this
jq --argfile bosh bosh.json '. = $bosh' model.json
yields the incorrect keys...
{
"key_pair_name": "my-aws-keypair",
"ssh_private_key": "my-key-name",
"trusted_certificates": "my-trusted-certs"
}
Does anyone have any ideas how to get the expected results using jq? by the way, I cannot use the value of the key for the updates, as i will have unexpected results in other permutations...