Zrythm v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
project_json_serializer.h
1// SPDX-FileCopyrightText: © 2026 Alexandros Theodotou <alex@zrythm.org>
2// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4#pragma once
5
6#include <string_view>
7
8#include "utils/version.h"
9
10#include <nlohmann/json_fwd.hpp>
11
12namespace zrythm::structure::project
13{
14class Project;
15class ProjectUiState;
16}
17
18namespace zrythm::undo
19{
20class UndoStack;
21}
22
23namespace zrythm::controllers
24{
25
26using namespace std::string_view_literals;
27
39{
40public:
41 static constexpr utils::Version SCHEMA_VERSION{ 2, 1, {} };
42 static constexpr auto DOCUMENT_TYPE = "ZrythmProject"sv;
43 static constexpr auto kProjectData = "projectData"sv;
44 static constexpr auto kUiState = "uiState"sv;
45 static constexpr auto kUndoHistory = "undoHistory"sv;
46 static constexpr auto kDatetimeKey = "datetime"sv;
47 static constexpr auto kTitle = "title"sv;
48
59 static nlohmann::json serialize (
60 const structure::project::Project &project,
62 const undo::UndoStack &undo_stack,
63 const utils::Version &app_version,
64 std::string_view title);
65
72 static void validate_json (const nlohmann::json &j);
73
83 static void deserialize (
84 const nlohmann::json &j,
87 undo::UndoStack &undo_stack);
88};
89
90}
Handles serialization, deserialization, and validation of project JSON.
static void validate_json(const nlohmann::json &j)
Validates JSON against the project schema.
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 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.
Serializable UI state for a project.
Core functionality of a Zrythm project.
Definition project.h:48
Represents a semantic version with major, minor, and optional patch.
Definition version.h:29