Remove the deeply nested structure from the JSON and simplify it
I have a JSON which has deep nested structure, I want a generic function in Javascript/Typescript to remove that multiple deep structure. Generic like there might me any parent other than categories
that may have nesting in its keys.
Here is an example JSON with deep nesting:-