MayaFlux 0.5.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
MayaFlux::IO::Serializer< T > Struct Template Reference

Extension point for JSONSerializer. More...

#include <Serializer.hpp>

+ Collaboration diagram for MayaFlux::IO::Serializer< T >:

Static Public Member Functions

static void from_json (const nlohmann::json &j, T &out)
 
static nlohmann::json to_json (const T &val)
 

Detailed Description

template<typename T>
struct MayaFlux::IO::Serializer< T >

Extension point for JSONSerializer.

Specialize this struct for any type that JSONSerializer does not handle natively. The specialization must provide: static nlohmann::json to_json(const T&); static void from_json(const nlohmann::json&, T&);

Example — adding support for a custom Vec3 type:

template <>
struct Serializer<MyVec3> {
static nlohmann::json to_json(const MyVec3& v) {
return nlohmann::json::array({ v.x, v.y, v.z });
}
static void from_json(const nlohmann::json& j, MyVec3& out) {
out = { j[0], j[1], j[2] };
}
};
Extension point for JSONSerializer.

Definition at line 30 of file Serializer.hpp.


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