0

If i have two json files, how can I combine the objects using powershell? I would like the values in the second file to supersede the values from the first object. There is possibly nested complex objects within the json. Really I'm looking for a modern solution to ($Json1 ConvertFrom-Json) | Merge ($Json2 ConvertFrom-Json) | ConvertTo-Json as Merge is deprecated, and i cannot use that in my azure pipeline.

{
"name" : "value",
"type": "someType",
"color": "green",
"someComplexObject" : value of complex object
}
{
"name" : "value1",
"color": "blue",
"someComplexObject" : value of complex object
}

Where the final result would be

{
"name" : "value1",
"type": "someType",
"color": "blue",
"someComplexObject" : value of complex object
}
bgibers
  • 200
  • 10

1 Answers1

-1

Merge/Concatenate multiple json files using PowerShell

TL;DR

@($JSON1; $JSON2) | ConvertTo-Json -Depth 20