DotNameLib
Loading...
Searching...
No Matches
dotnamecpp::utils::IJsonSerializer Class Referenceabstract

Interface for JSON serialization and parsing. More...

#include <IJsonSerializer.hpp>

Inheritance diagram for dotnamecpp::utils::IJsonSerializer:
Collaboration diagram for dotnamecpp::utils::IJsonSerializer:

Public Member Functions

virtual ~IJsonSerializer ()=default
virtual Result< nlohmann::json, JsonErrorloadFromFile (const std::filesystem::path &filePath) const =0
 Load JSON from file.
virtual Result< void, JsonErrorsaveToFile (const std::filesystem::path &filePath, const nlohmann::json &jsonData, int indent=2) const =0
 Save JSON to file.
virtual Result< nlohmann::json, JsonErrorparse (const std::string &jsonString) const =0
 Parse JSON from string.
virtual Result< std::string, JsonErrortoString (const nlohmann::json &jsonData, int indent=2) const =0
 Convert JSON to string.

Detailed Description

Interface for JSON serialization and parsing.

Provides safe JSON operations with Result<T,E> error handling.

Constructor & Destructor Documentation

◆ ~IJsonSerializer()

virtual dotnamecpp::utils::IJsonSerializer::~IJsonSerializer ( )
virtualdefault

Member Function Documentation

◆ loadFromFile()

virtual Result< nlohmann::json, JsonError > dotnamecpp::utils::IJsonSerializer::loadFromFile ( const std::filesystem::path & filePath) const
nodiscardpure virtual

Load JSON from file.

Parameters
filePath
Returns
Result<nlohmann::json, JsonError>

Implemented in dotnamecpp::utils::JsonSerializer.

◆ parse()

virtual Result< nlohmann::json, JsonError > dotnamecpp::utils::IJsonSerializer::parse ( const std::string & jsonString) const
nodiscardpure virtual

Parse JSON from string.

Parameters
jsonString
Returns
Result<nlohmann::json, JsonError>

Implemented in dotnamecpp::utils::JsonSerializer.

◆ saveToFile()

virtual Result< void, JsonError > dotnamecpp::utils::IJsonSerializer::saveToFile ( const std::filesystem::path & filePath,
const nlohmann::json & jsonData,
int indent = 2 ) const
nodiscardpure virtual

Save JSON to file.

Parameters
filePath
jsonData
indentIndentation level (default: 2)
Returns
Result<void, JsonError>

Implemented in dotnamecpp::utils::JsonSerializer.

◆ toString()

virtual Result< std::string, JsonError > dotnamecpp::utils::IJsonSerializer::toString ( const nlohmann::json & jsonData,
int indent = 2 ) const
nodiscardpure virtual

Convert JSON to string.

Parameters
jsonData
indentIndentation level (default: 2)
Returns
Result<std::string, JsonError>

Implemented in dotnamecpp::utils::JsonSerializer.


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