Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
zrythm::controllers::ProjectJsonSerializer Class Reference

Handles serialization, deserialization, and validation of project JSON. More...

#include <src/controllers/project_json_serializer.h>

Collaboration diagram for zrythm::controllers::ProjectJsonSerializer:

Static Public Member Functions

static nlohmann::json serialize (const structure::project::Project &project, const structure::project::ProjectUiState &ui_state, const undo::UndoStack &undo_stack, const utils::Version &app_version, std::string_view title)
 Returns a json representation of the project.
static void validate_json (const nlohmann::json &j)
 Validates JSON against the project schema.
static void deserialize (const nlohmann::json &j, structure::project::Project &project, structure::project::ProjectUiState &ui_state, undo::UndoStack &undo_stack)
 Loads and validates a project from JSON.

Static Public Attributes

static constexpr utils::Version SCHEMA_VERSION { 2, 1, {} }
static constexpr auto DOCUMENT_TYPE = "ZrythmProject"sv
static constexpr auto kProjectData = "projectData"sv
static constexpr auto kUiState = "uiState"sv
static constexpr auto kUndoHistory = "undoHistory"sv
static constexpr auto kDatetimeKey = "datetime"sv
static constexpr auto kTitle = "title"sv

Detailed Description

Handles serialization, deserialization, and validation of project JSON.

This class coordinates the serialization of all project-related data:

  • Core Project data (under "projectData" key)
  • UI state like snap grids (under "uiState" key)
  • Undo/redo history (under "undoHistory" key)

The output follows the project schema (data/schemas/project.schema.json).

Definition at line 38 of file project_json_serializer.h.

Member Function Documentation

◆ deserialize()

void zrythm::controllers::ProjectJsonSerializer::deserialize ( const nlohmann::json & j,
structure::project::Project & project,
structure::project::ProjectUiState & ui_state,
undo::UndoStack & undo_stack )
static

Loads and validates a project from JSON.

Parameters
jThe JSON to deserialize.
projectThe project instance to populate.
ui_stateThe UI state instance to populate.
undo_stackThe undo stack instance to populate.
Exceptions
std::runtime_erroron validation or load error.

◆ serialize()

nlohmann::json zrythm::controllers::ProjectJsonSerializer::serialize ( const structure::project::Project & project,
const structure::project::ProjectUiState & ui_state,
const undo::UndoStack & undo_stack,
const utils::Version & app_version,
std::string_view title )
static

Returns a json representation of the project.

Parameters
projectThe project to serialize.
ui_stateThe UI state to serialize.
undo_stackThe undo stack to serialize.
app_versionVersion of the application.
titleProject title.
Exceptions
std::runtime_erroron error.

◆ validate_json()

void zrythm::controllers::ProjectJsonSerializer::validate_json ( const nlohmann::json & j)
static

Validates JSON against the project schema.

Parameters
jThe JSON to validate.
Exceptions
std::runtime_errorif validation fails.

Field Documentation

◆ DOCUMENT_TYPE

auto zrythm::controllers::ProjectJsonSerializer::DOCUMENT_TYPE = "ZrythmProject"sv
staticconstexpr

Definition at line 42 of file project_json_serializer.h.

◆ kDatetimeKey

auto zrythm::controllers::ProjectJsonSerializer::kDatetimeKey = "datetime"sv
staticconstexpr

Definition at line 46 of file project_json_serializer.h.

◆ kProjectData

auto zrythm::controllers::ProjectJsonSerializer::kProjectData = "projectData"sv
staticconstexpr

Definition at line 43 of file project_json_serializer.h.

◆ kTitle

auto zrythm::controllers::ProjectJsonSerializer::kTitle = "title"sv
staticconstexpr

Definition at line 47 of file project_json_serializer.h.

◆ kUiState

auto zrythm::controllers::ProjectJsonSerializer::kUiState = "uiState"sv
staticconstexpr

Definition at line 44 of file project_json_serializer.h.

◆ kUndoHistory

auto zrythm::controllers::ProjectJsonSerializer::kUndoHistory = "undoHistory"sv
staticconstexpr

Definition at line 45 of file project_json_serializer.h.

◆ SCHEMA_VERSION

utils::Version zrythm::controllers::ProjectJsonSerializer::SCHEMA_VERSION { 2, 1, {} }
staticconstexpr

Definition at line 41 of file project_json_serializer.h.


The documentation for this class was generated from the following file: