Suppose I have a kind of UML activity diagram with 1-n forks and joins.
The assignment of the individual nodes relative to each other is defined by an XML relationship table via UUIDs where each source
and target
attribute's UUID represents such an individual node.
The following, highlighted example should clarify this:
The UML diagram flow starts at
source = "b1edbc32-a6f0-4a41-a836-0482d80db226"
(connection node 1)
and ends with
target = "ef347ef9-3b53-45ab-918e-6f8b29a68dc0"
(connection node 5)
In between you can see in the "flow" from one (or more) sources to one (or more) targets. The exemplary fork/join is colored in green/light blue.
I would now like to map this structure into a nested JSON array, e.g.
"nodes": [
{
"name": "initNode",
"uid": "b1edbc32-a6f0-4a41-a836-0482d80db226",
"nodes": [
{
"name": "followUpNode",
"uid": "9ea88f3e-4b80-473d-a86f-0ff16b790727",
"nodes": [
// ...
]
}
]
}
]
What's the best suited programming approach to achieve this with Qt5 C++ utilizing QDom... and QJson... stuff? I just need some thought-provoking impulses.
Some kind of looping....or recursion?
While JSON as the data format for the output is mandatory, the shown JSON example layout is not. If there's a better approach than those nested nodes
arrays (how to handle the multiple fork/join parallelism?!) then please let me know, too.
Any example is appreciated!