Could someone tell me why particular key value getting repeat in object?
I've data like below getting from response like below.
var data = {
"sub": {
"LoadTime on linkedShip": "01:25:00 AM",
"business Limit": "300",
"avoid goods": "50",
"avoid goods_Group": "100",
"isPermanent": "['permLinkAccount']",
"transport Limit": "1",
"hasDailySlot": "1"
}
};
trying to replace "isPermanent": "['permLinkAccount']" to "isPermanent":"permLinkAccount" without changing other stuffs in object.
if (data.sub.hasOwnProperty("isPermanent")) {
data = JSON.parse(JSON.stringify(data).replace(/[\[\]']/g,"permLinkAccount"));
console.log('data', data);
}
but getting like
isPermanent: "permLinkAccountpermLinkAccountpermLinkAccountpermLinkAccountpermLinkAccount" instead of "isPermanent":"permLinkAccount"
I need like
LoadTime on linkedShip: "01:25:00 AM"
avoid goods: "50"
avoid goods_Group: "100"
business Limit: "300"
hasDailySlot: "1"
isPermanent: "permLinkAccount"
transport Limit: "1"
What is wrong here?