Zrythm v2.0.0-alpha.1
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
42 SCHEMA_VERSION{ .major = 2, .minor = 1, .patch = {} };
43 static constexpr auto DOCUMENT_TYPE = "ZrythmProject"sv;
44 static constexpr auto kProjectData = "projectData"sv;
45 static constexpr auto kUiState = "uiState"sv;
46 static constexpr auto kUndoHistory = "undoHistory"sv;
47 static constexpr auto kDatetimeKey = "datetime"sv;
48 static constexpr auto kTitle = "title"sv;
49
60 static nlohmann::json serialize (
61 const structure::project::Project &project,
63 const undo::UndoStack &undo_stack,
64 const utils::Version &app_version,
65 std::string_view title);
66
73 static void validate_json (const nlohmann::json &j);
74
84 static void deserialize (
85 const nlohmann::json &j,
88 undo::UndoStack &undo_stack);
89};
90
91}
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:54
Represents a semantic version with major, minor, and optional patch.
Definition version.h:29