0

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.

4
  • 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. Commented 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? Commented 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/… Commented 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. Commented Apr 7, 2016 at 13:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.