Try OpenEdge Now
skip to main content
Programming Interfaces
Data Management : ABL API for Multi-tenant and Table Partition Management : Exporting and importing : Exporting and importing objects as JSON files
 
Exporting and importing objects as JSON files
Both entity and entity collection objects support overloadings of the Export( ) and Import( ) methods using a format to store and retrieve object data similar to the ABL WRITE-JSON( ) and READ-JSON( ) methods (respectively) on a temp-table. In addition, these objects support ExportTree( ) and ImportTree( ) methods that export and import an entire object, including all child collections. The ExportTree( ) method is overloaded with a parameter to specify what collections to export. The ExportTree( ) and ImportTree( ) methods use a format to store and retrieve object data similar to the ABL WRITE-JSON( ) and READ-JSON( ) methods (respectively) on a ProDataSet.
The following code exports all tenants in the database into a JSON (.json) file:
tenantCol = service:GetTenants().
tenantCol:Export("mytenants.json").
The following code loads new tenants from a JSON file and into the database:
tenantCol = new TenantSet().
tenantCol:Import("mytenants.json").
service:CreateTenants(tenantCol).
This import can also be done on existing tenants as shown using the ImportTree( ) method in a following example.
The following code exports all tenants and partitions in the database into a JSON file:
tenantCol = service:GetTenants().
tenantCol:ExportTree("mytenants.json","partitions").
The following code imports tenants and any child objects from the specified JSON file into the database:
tenantCol = service:GetTenants().
tenantCol:ImportTree("mytenants.json").
service:UpdateTenants(tenantCol).
This import can also be done for new tenants as shown using the Import( ) method in a previous example.