I have a file with data that looks like that :
ID attribute
1 'text'
101 'text'
1011 'text'
10111 'text'
1011101 'text'
1011102 'text'
1011103 'text'
1011104 'text'
1011130 'text'
My goal is to build json tree structure from these data :
{
[
ID : 1,
attribute : 'text',
children : [
ID: 101,
attribute : 'text',
children : [
...
ID : 2,
...
]
}
In python, i builded a list of dictionnaries like that :
[ {'id': ID, 'attr' : text}, {...} ]
I think i could use the fact that leaf id contain his parents id but i can’t see the way to build the structure i want.
I would appreciate any help, in pseudo code or any other programming langage.
Solution from thg435 worked with little changes :
Thanks !