I have a JSON data structure that looks like this
{
"array": {
"InvestmentsDeposits": {
"NAME": "Investments & Deposits",
"PARENT": [
{
"CONTENT_ID": "Promotions",
"DISPLAY_ORDER": 3,
"PATH": "/Promotions"
}
]
},
"InvestmentsDeposits$$$d": {
"NAME": "Deposits",
"PARENT": [
{
"CONTENT_ID": "NewPromotion",
"text" : "newtext"
}
]
}
}
}
I am seeking to find and merge similar data using fuzzy logic. For example, InvestmentsDeposits and InvestmentsDeposits$$$d should be merged because they are closely matched in name
My objective is to accomplish this task using javascript
Currently, I can ensure that the source data always contains $$$d at the end to facilitate merging with target data lacking $$$d, such as InvestmentDeposits.
The resulting merged content should resemble this
{
"array": {
"InvestmentsDeposits": {
"NAME": "Deposits",
"PARENT": [
{
"CONTENT_ID": "NewPromotion",
"DISPLAY_ORDER": 3,
"PATH": "/Promotions"
"text": "newtext"
}
]
}
}
}
Any assistance on this matter?
Here's what I have attempted thus far
var json0 = {
"InvestmentsDeposits": {
"NAME": "Investments & Deposits",
"PARENT": [
{
"CONTENT_ID": "Promotions",
"DISPLAY_ORDER": 3,
"PATH": "/Promotions"
}
]
}
};
var json1 =
{
"InvestmentsDeposits$$$d": {
"NAME": "Deposits",
"PARENT": [
{
"CONTENT_ID": "NewPromotion",
"text" : "newtext"
}
]
}
};
// Merge object2 into object1, recursively
$.extend( true, json0, json1 );
I am able to merge the data if I can separate the InvestmentDeposits and InvestmentDeposits$$$d into two distinct JSON objects, but how can I split and relocate the $$$d data into another object for the jquery extend method to work properly?