So I have an interesting challenge while working on my project. I need help figuring out how to split a Javascript Object like the one below:
{
field1: {
field2: {
field3: "value 1",
field4: "value 2"
}
}
}
My goal is to separate any field with multiple keys into different arrays, as shown here:
[
{
field1: {
field2: {
field3: "value 1"
}
}
},
{
field1: {
field2: {
field4: "value 2"
}
}
}
]
I've attempted to create recursive functions to navigate through the object structure and duplicate any object value with more than one key. Each "child" should have its own parent structure. I feel like there might be a simple solution that I'm missing, so any suggestions would be greatly appreciated!
Thank you for your help.