-2

I have a following list of objects :-

    [
      {
      "tenantId": "ramyam101",
      "tenantName": "Level1-Tenant-OOUF",
      "parentName": "None",
      "tenantAccountType": "Organization-Only User Function",
      "index": 0,
      "tenantLogoBase64": ""
      },
      {
      "tenantId": "ramyam102",
      "tenantName": "Level2-Tenant-OOUF",
      "parentName": "Level1-Tenant-OOUF",
      "tenantAccountType": "Organization-Only User Function",
      "index": 1,
      "tenantLogoBase64": ""
      },
      {
      "tenantId": "ramyam103",
      "tenantName": "Level3-Tenant-OF",
      "parentName": "Level2-Tenant-OOUF",
      "tenantAccountType": "Organization Functional",
      "index": 2,
      "tenantLogoBase64": ""
      },
      {
      "tenantId": "ramyam104",
      "tenantName": "Level3-Tenant-OOUF",
      "parentName": "Level2-Tenant-OOUF",
      "tenantAccountType": "Organization-Only User Function",
      "index": 2,
      "tenantLogoBase64": ""
      }
    ]

This represents a hierarchy tree where each entry in the list has a 'tenantName' & 'parentName' and the level of the tenant in the hierarchy which is represented by 'index'.

For Example :-

                          Level1-Tenant-OOUF
                           |
               Level2-Tenant-OOUF
                 |           |   
    Level3-Tenant-OF     Level3-Tenant-OOUF

So I want to create a nested structure which has child node objects inside the parent object. How can I do this ? Please help me out...!

Vivek Sharma
  • 103
  • 2
  • 11
  • 1
    That is obviously [JSON](http://json.org/) format so use the [JSON API](http://www.oracle.com/technetwork/articles/java/json-1973242.html)!? :D – xander Mar 28 '17 at 06:47
  • if You have a clear idea of the structure which is your model, you can use different libraries to parse this JSON, 1 min google search would get you there – Amer Qarabsa Mar 28 '17 at 06:49
  • you want to present data in heirarichal form ? right ?? – Vikrant Kashyap Mar 28 '17 at 06:49

1 Answers1

1

The following post might help you. It is using javascript to form the JSON. You might take help from this script how it is building the JSON so you can be able to make according to your JSON.

Hierarchical json from flat with parent ID

Community
  • 1
  • 1
Arindam
  • 555
  • 1
  • 8
  • 24