Export JSON Data with Slinks
Why Export Slinks?
Slinks are an invaluable feature in organizational charts because they represent relationships that do not fit into the standard parent-child hierarchy. They can be used to show:
- Cross-departmental collaboration
- Reporting structures to multiple managers
- Task dependencies or special project assignments
Exporting this data ensures that these important relationships are not lost when you save or share your chart. A standard JSON export of nodes alone does not include this information, because it is stored separately in the chart configuration.
The Solution: onExportEnd Event
The key to exporting slinks is the onExportEnd event provided by OrgChart JS. This event fires after a successful export, so you can run custom logic. Here, we check whether the export type is JSON and then trigger a second download for slinks.
The slinks.json file contains a clean array of slink objects, including fields such as from, to, and optional properties like label or template.
This two-file export approach gives you a complete record of your organization structure: one file for nodes and one for slinks.