MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ decode()

template<typename T >
std::optional< T > MayaFlux::IO::JSONSerializer::decode ( const std::string &  str)
inline

Parse str and deserialize into T.

Returns
Populated instance, or nullopt on any parse or structural error. On failure call last_error().

Definition at line 88 of file JSONSerializer.hpp.

89 {
90 m_last_error.clear();
91 try {
92 auto j = nlohmann::json::parse(str);
93 T out {};
94 from_json(j, out);
95 return out;
96 } catch (const std::exception& e) {
97 m_last_error = std::string("decode error: ") + e.what();
98 return std::nullopt;
99 }
100 }
static void from_json(const nlohmann::json &j, T &out)

References MayaFlux::IO::T.