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

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

#include <src/structure/project/project_json_serializer.h>

Collaboration diagram for zrythm::structure::project::ProjectJsonSerializer:

Static Public Member Functions

static nlohmann::json serialize (const Project &project, 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, Project &project)
 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 kDatetimeKey = "datetime"sv
static constexpr auto kTitle = "title"sv

Detailed Description

Handles serialization, deserialization, and validation of Project JSON.

This class manages converting Project objects to/from JSON format according to the project schema (data/schemas/project.schema.json), and validates JSON against that schema.

Definition at line 25 of file project_json_serializer.h.

Member Function Documentation

◆ deserialize()

void zrythm::structure::project::ProjectJsonSerializer::deserialize ( const nlohmann::json & j,
Project & project )
static

Loads and validates a project from JSON.

Parameters
jThe JSON to deserialize.
projectThe project instance to populate.
Exceptions
std::runtime_erroron validation or load error.

◆ serialize()

nlohmann::json zrythm::structure::project::ProjectJsonSerializer::serialize ( const Project & project,
const utils::Version & app_version,
std::string_view title )
static

Returns a json representation of the project.

Parameters
projectThe project to serialize.
app_versionVersion of the application.
titleProject title.
Exceptions
std::runtime_erroron error.

◆ validate_json()

void zrythm::structure::project::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::structure::project::ProjectJsonSerializer::DOCUMENT_TYPE = "ZrythmProject"sv
staticconstexpr

Definition at line 29 of file project_json_serializer.h.

◆ kDatetimeKey

auto zrythm::structure::project::ProjectJsonSerializer::kDatetimeKey = "datetime"sv
staticconstexpr

Definition at line 31 of file project_json_serializer.h.

◆ kProjectData

auto zrythm::structure::project::ProjectJsonSerializer::kProjectData = "projectData"sv
staticconstexpr

Definition at line 30 of file project_json_serializer.h.

◆ kTitle

auto zrythm::structure::project::ProjectJsonSerializer::kTitle = "title"sv
staticconstexpr

Definition at line 32 of file project_json_serializer.h.

◆ SCHEMA_VERSION

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

Definition at line 28 of file project_json_serializer.h.


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