json-document-transforms
json-document-transforms copied to clipboard
Easier way to replace an array?
Under the "Default Transformation" section there is an array listed as "SupportedVersions" that says the default transformation for arrays is append but when going to the "Replace" section, it does not show how to replace an array.
Let's assume I have 2 appsettings.json files that need merged so that the SupportedVersions array is replaced when listed under the Settings section.
First file
{
"Settings": {
"SupportedVersions" : [1, 2]
}
}
Second file
{
"Settings": {
"SupportedVersions" : [3, 4]
}
}
Expected output
{
"Settings": {
"SupportedVersions" : [3, 4]
}
}
I can get this to work by using the following but is there an easier way that I can't find in the documentation? This works but is long
{
"Settings": {
"@jdt.replace" : {
"@jdt.path" : "$.SupportedVersions",
"@jdt.value" : [3, 4]
}
}
}