I have in JavaScript JSON object the following code:
{
apple: 'value',
orange: 'value',
string1Pear: 'value',
string1Banana: 'value',
string2Pear: 'value',
string2Banana: 'value',
pineapple: 'value'
}
I need to group the similar keys for a given object without knowing if there is there is such or what they would look like.
The end result should be something like this:
{
apple: 'value',
orange: 'value',
string: {
string1: {
string1Pear: 'value',
string1Banana: 'value',
},
string2: {
string2Pear: 'value',
string2Banana: 'value',
},
}
pineapple: 'value'
}