I have two json files, and I want to combine one json file as object to another json file.
My first C1
json like:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"connections_TestValue_name": {
"defaultValue": "TestValue",
"type": "String"
}
},
"variables": {},
"resources": []
}
And another C2
json like:
{
"kind": "V2",
"properties": {
"displayName": "XXXX.XXX",
"authenticatedUser": {
"name": "XXX.XXX"
},
"overallStatus": "Connected",
"statuses": [
{
"status": "Connected"
}
],
"connectionState": "Enabled",
"parameterValues": {
},
"customParameterValues": {
...
...
}
Now, I need to insert Json file C2
as object "resources": []
to another json file C1
, like:
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"connections_TestValue_name": {
"defaultValue": "TestValue",
"type": "String"
}
},
"variables": {},
"resources": [
{
"kind": "V2",
"properties": {
...
...
}
]
}
Note: C1
, C2
are not actual files, they are obtained by other scripts.
2
Answers
Since I'm not an expert in powershell, I found the answer after many tries and debugging:
Direction: