I'm completely new on SwiftUI and trying to load a json file with data containing a tree structure with items of this type:
struct Node : Identifiable {
id = UUID()
name : String
childNodes : [Node]
}
It is unknown beforehand how deep the data structure goes with child nodes.
Have tried to just decode
guard let results = try? decoder.decode(Node.self, from: filedata) else {
fatalError("Decode error")
which seems to work, until I try to use the data. Guess it might have to do with the fact that the childNodes array is empty at some level.
What would be the best way to accomplish this?