libnick 2025.9.1
A cross-platform base for native Nickvision applications.
Loading...
Searching...
No Matches
ijsonserializable.h
Go to the documentation of this file.
1#ifndef IJSONSERIALIZABLE_H
2#define IJSONSERIALIZABLE_H
3
4#include <string>
5#include <type_traits>
6#include <boost/json.hpp>
7
9{
14 {
15 public:
16 virtual ~IJsonSerializable() = default;
21 virtual boost::json::value toJson() const noexcept = 0;
22 };
23
24 template<typename T>
25 concept DerivedJsonSerializable = std::is_base_of_v<IJsonSerializable, T>;
26
27 template<typename T>
28 concept SupportedJsonValue = std::is_same_v<T, int> ||
29 std::is_same_v<T, std::int64_t> ||
30 std::is_same_v<T, double> ||
31 std::is_same_v<T, bool> ||
32 std::is_same_v<T, std::string> ||
33 std::is_same_v<T, boost::json::array> ||
34 std::is_same_v<T, boost::json::object>;
35}
36
37#endif //IJSONSERIALIZABLE_H
An interface for objects serializable to Json.
Definition ijsonserializable.h:14
virtual boost::json::value toJson() const noexcept=0
Serializes the object to Json.
Definition ijsonserializable.h:25
Definition ijsonserializable.h:28
Definition cancellationtoken.h:30