Is there some simple way to extend one JSON file with another and save the output to yet another file using PowerShell? Currently I'm attempting to write a recurrent function that will allow me to do that*, but maybe there is a simpler solution out there?
*iterate over properties of a JSON converted to a PSCustomObject
and replace them if needed (actually check my answer below)
Edit: I need to do something similar to what jquery.extend does so, my input is:
{
"name": "Some name",
"value": 1,
"config": {
"debug": false,
"output": "c:\\"
}
}
And
{
"value": 2,
"config": {
"debug": true
},
"debug": {
"log": true
}
}
And my output is supposed to be:
{
"name": "Some name",
"value": 2,
"config": {
"debug": true,
"output": "c:\\"
},
"debug": {
"log": true
}
}
P.S. Generally I need to write a script that can be run from a batch file and does not require 3rd party libraries (is limited to Windows resources). I tried my luck with Cscript JavaScript, but I decided against using it when I found out, that the only built in method to parse JSON is to eval it.