Here's an array of objects:
p =[
{
"object1": "value",
},
{
"object2": "value",
},
{
"object1": "value",
},
{
"object3": "value",
},
{
"object4": "value",
},
{
"object1": "value",
},
{
"object3": "value"
}
];
I'm looking to adjust the keys of objects that share the same key. Any thoughts on how I can achieve this?
The desired output should be:
p =[
{
"object1_1": "value",
},
{
"object2": "value",
},
{
"object1_2": "value",
},
{
"object3_1": "value",
},
{
"object4": "value",
},
{
"object1_3": "value",
},
{
"object3_2": "value",
}
];
The goal is to maintain the structure of the array as much as possible, with the only changes being updates to duplicate keys.