So I have a custom class RootElement, which currently is the final object that I transform into Json (using JsonSerializer). The terms have changed, and now I need it to be a flat list. The RootElement has a list of StartElements, and each following element is accessed with the Next-Property, creating a tree structure. How can I get these elements and put them into a List Property? Is there a way to do it with the getter of that property? I need to keep the order of the elements. Not sure if code would be useful, I wouldn't know what do put here.
-
Why do you need a flat list? Taking a tree structure and making it flat looses information. If you do need a flat list then assign node numbers in flat list and add a parent/child column to flat list (node number of child and parent) so you can keep parent child relationships.jdweng– jdweng2016-04-07 12:11:01 +00:00Commented Apr 7, 2016 at 12:11
-
I think you're right. I don't need a flat list, but I do need a list of all the Elements that I get through the Next-Property, their properties can stay in parent child relationships. I just them to be on the same level in the Json output. Does that make sense?tweedledum11– tweedledum112016-04-07 12:32:10 +00:00Commented Apr 7, 2016 at 12:32
-
Yes it makes sense. The best way is to use a recursive method. See following webpage : stackoverflow.com/questions/2572721/…jdweng– jdweng2016-04-07 12:49:12 +00:00Commented Apr 7, 2016 at 12:49
-
Thanks very much, I'll have a look at that. I'll comment again if that doesn't help me.tweedledum11– tweedledum112016-04-07 13:10:11 +00:00Commented Apr 7, 2016 at 13:10
Add a comment
|