I would like to update the matching keys from one json array with a subset from a different json array.
I have a global json config like this:
var config_global = {
"appArr": {
"app1": {
"id": "ID_001",
"name": "Application 1",
"url": "https://app1.html",
"is_visible": true,
"in_list": true,
},
"app1": {
"id": "ID_002",
"name": "Application 2",
"url": "https://app2.html",
"is_visible": true,
"in_list": true,
},
"app1": {
"id": "ID_003",
"name": "Application 3",
"url": "https://app3.html",
"is_visible": true,
"in_list": true,
}
}
}
I would like to have another json array that will keep all the sub-keys and only update the items in my second json array:
var config_local = {
"appArr": {
"app1": {
"is_visible": false,
"in_list": true,
},
"app1": {
"is_visible": false,
"in_list": false,
},
"app1": {
"is_visible": true,
"in_list": false,
}
}
}
The final config must have the complete config_global with the updates from config_local.
I tried using Oject.assign(), but this replaces the app configs instead of updating it.
The final config should look like this:
var config = {
"appArr": {
"app1": {
"id": "ID_001",
"name": "Application 1",
"url": "https://app1.html",
"is_visible": false,
"in_list": true,
},
"app1": {
"id": "ID_002",
"name": "Application 2",
"url": "https://app2.html",
"is_visible": false,
"in_list": false,
},
"app1": {
"id": "ID_003",
"name": "Application 3",
"url": "https://app3.html",
"is_visible": true,
"in_list": false,
}
}
}
Thank you very much for any assistance.