Hi there
Can anyone please help with a snippet to unflatten data into a json stree?
For example, this is my list of records...
To something like...
Can anyone please help with a snippet to unflatten data into a json stree?
For example, this is my list of records...
B4X:
Dim arr As List
arr.Initialize
arr.Add(CreateMap("id":1 ,"parentid" : 0))
arr.Add(CreateMap("id":4 ,"parentid" : 2))
arr.Add(CreateMap("id":3 ,"parentid" : 1))
arr.Add(CreateMap("id":5 ,"parentid" : 0))
arr.Add(CreateMap("id":6 ,"parentid" : 0))
arr.Add(CreateMap("id":2 ,"parentid" : 1))
arr.Add(CreateMap("id":7 ,"parentid" : 4))
arr.Add(CreateMap("id":8 ,"parentid" : 1))
To something like...
B4X:
[
{
"id": 1,
"parentid": 0,
"children": [
{
"id": 2,
"parentid": 1,
"children": [
{
"id": 4,
"parentid": 2,
"children": [
{
"id": 7,
"parentid": 4,
"children": []
....
....
}