I have a json object I would like to modify. This is data:
var data1 = {
"[email protected]": {
"[email protected]": {
"[email protected]": {
"[email protected]": {
"[email protected]": {}
},
"[email protected]": {}
},
"[email protected]": {
"[email protected]": {}
}
},
"[email protected]": {}
}
};
basically for every key, a the left of '@'
I want to add char + sum of every number on the right and on the right replace all '.'
with '-'
. For example, if key is '[email protected]
', my new key will be 'abcd17@1-12-4'
.
for this example I want this as result:
var data2 = {
"a4@1-0-3": {
"b5@2-3-0": {
"c2@2-0-0": {
"d4@0-4-0": {
"e3@1-1-1": {}
},
"f8@0-5-3": {}
},
"j19@2-15-2": {
"x6@1-2-3": {}
}
},
"i14@1-5-8": {}
}
};
can you please help ?