![]() |
fpmas 1.6
|
#include <json_datapack.h>
Static Public Member Functions | |
template<typename JsonType > | |
static void | to_json (JsonType &json, const T &data) |
template<typename JsonType > | |
static T | from_json (const JsonType &json) |
An nlohmann serializer implementation based on object pack serialization.
Objects of type T are serialized using the fpmas::io::datapack library. ObjectPacks are then written and read directly to json as strings.
More particularly, the type T must be serializable into the provided PackType
, that is itself based on fpmas::io::datapack::BasicObjectPack. For example, if PackType
is fpmas::io::datapack::ObjectPack, the classical fpmas::io::datapack::Serializer custom serialization rules must be provided.
An fpmas::io::datapack::LightSerializer specialization must be provided for T when PackType
is fpmas::io::datapack::LightObjectPack. See fpmas::io::datapack for more information.
T | type to serialize |
PackType | object pack type used for serialization (fpmas::io::datapack::ObjectPack, fpmas::io::datapack::LightObjectPack,...) |
|
inlinestatic |
Serializes data
to json
.
An std::string instance is produced from the DataPack generated by PackType(data)
and written to json
.
json | destination json |
data | data to serialize |
|
inlinestatic |
Unserializes data from json
.
A raw DataPack is retrieved from the pack and parsed using PackType::parse()
, and an instance of T is unserialized using the PackType::get()
method.
json | source json |