JSON Project Import And Export
JSON project import/export provides a framework-neutral way to move complete Gantt project snapshots between files, APIs, tests, undo buffers, and server-side workflows. The helpers operate on ProjectSnapshot data only. They do not depend on the grid, DOM, or framework wrappers.
Import the helpers from Enterprise:
import { cloneProjectSnapshot, createJsonSnapshotRecipe, exportProjectSnapshot, parseProjectSnapshotJson,} from '@revolist/revogrid-enterprise';Export A Snapshot
Section titled “Export A Snapshot”Use exportProjectSnapshot() to serialize the current project snapshot.
const json = exportProjectSnapshot(project, { space: 2 });The optional space value is passed to JSON.stringify, so you can use it for readable file exports.
Import A Snapshot
Section titled “Import A Snapshot”Use parseProjectSnapshotJson() to parse JSON into a typed result instead of throwing for common invalid payloads.
const parsed = parseProjectSnapshotJson(json);
if (!parsed.ok) { showImportError(parsed.error); return;}
applyProject(parsed.project);The parser checks the top-level project shape:
- Required string fields:
id,name,version,currency,timeZone,primaryCalendarId, andupdatedAt. - Required array fields:
tasks,dependencies,resources,assignments,calendars, andbaselines.
It intentionally performs lightweight validation. Run scheduler validation or your application-specific validation after import when you need deeper checks for dates, task references, dependency cycles, resource assignments, or business rules.
Clone Before Editing
Section titled “Clone Before Editing”Use cloneProjectSnapshot() when you need a JSON-safe deep copy before staging edits.
const draft = cloneProjectSnapshot(project);draft.name = 'Scenario copy';The clone is detached from nested task, dependency, resource, assignment, calendar, and baseline arrays.
File Picker Recipe
Section titled “File Picker Recipe”For host applications that own file pickers and save dialogs, use createJsonSnapshotRecipe() with injected text readers and writers.
const recipe = createJsonSnapshotRecipe({ readText: () => selectedFile.text(), writeText: (fileName, contents) => downloadTextFile(fileName, contents), fileName: (project) => `${project.id}-snapshot.json`,});
const imported = await recipe.load();await recipe.save(project, 2);The recipe throws an Error when load/save hooks are missing or the imported JSON fails parsing. Use the lower-level parser directly when you prefer result objects over exceptions.
What The JSON Contains
Section titled “What The JSON Contains”The exported JSON is the project snapshot, not rendered grid state. It includes project metadata and entity arrays:
- Tasks
- Dependencies
- Resources
- Assignments
- Calendars
- Baselines
It does not include projected Gantt row fields, rendered timeline geometry, current scroll position, expanded row state, active selection, filters, or toolbar state.
Persistence Adapters
Section titled “Persistence Adapters”The REST, GraphQL, Supabase, and PostgreSQL examples build on the same JSON snapshot helpers. Use those adapters when the snapshot should be loaded from or saved to an application backend.
See Integrations And Frameworks for adapter examples.