I'm currently building an array of JSON objects for FancyTree (https://github.com/mar10/fancytree/wiki/TutorialLoadData). My JSON source is from the Jira REST service, and its structure can vary widely. Therefore, the code to construct the array of JSON objects needs to be adaptable and capable of handling any format.
Below is an example of the source JSON:
{
"feed": {
"entry": [
{
// Json content omitted for brevity
}
]
}
}
The challenge is to transform this data into a specific format as shown below:
[
{title: "Node 1", key: "1"},
{title: "Folder 2", key: "2", folder: true, children: [
{title: "Node 2.1", key: "3", myOwnAttr: "abc"},
{title: "Node 2.2", key: "4"},
{title: "Folder 3", key: "5", folder: true, children: [
{title: "Node 3.1", key: "6", myOwnAttr: "xyz"},
{title: "Node 3.2", key: "7"}
]}
]}
]
While attempting to achieve this transformation, I've encountered some difficulties with the current implementation. Any assistance or suggestions on improving the logic would be greatly appreciated. Thank you!