![]() |
fpmas 1.6
|
#include <json.h>
Static Public Member Functions | |
static void | to_json (light_json &j, const T &data) |
static void | from_json (const light_json &j, T &data) |
Default light_serializer
implementation, that automatically falls back to the classic nlohmann::adl_serializer
. In consequence, the light_serializer
is effective only when explicit specialization are provided (see for example light_serializer<NodePtrWrapper<T>>).
The definition of a custom json
type, light_json
, and the associated serializer, json_serializer
, allows to easily reuse classic adl_serializer
implementations when required.
For example, the serialization of a DistributedId is the same for a classic nlohmann::json
or for a light_json
, so we shall not need to provide two implementations with the same serialization rules. This is indeed not required, since nlohmann::adl_serializer<DistributedId> serialization rules are provided using templated to_json
and from_json
methods:
So, when it is required to serialize a DistributedId in the light_json
serialization process, the method above are automatically instantiated so that the same serialization rules are used for any JsonType
.
An other interesting use case occurs with DistributedEdges, where we typically want to use a light_json
, so that source and target nodes are transmitted using a light_json
: there is no need to serialize and transmit node data to instantiate a DistributedEdge.
However, the DistributedEdge serialization rules defined in adl_serializer<EdgePtrWrapper<T>> are the same for any JsonType, but that's not the case for the DistributedNode, where two serializer implementations are provided:
So even if the implementation of the DistributedEdge is unique, the proper DistributedNode serialization rules are automatically selected at compile time according to the provided JsonType
.
Concretely, DistributedEdges can be serialized more efficiently using a light_json
: see TypedMpi<DistributedEdge<T>>.
T | type to serialize |
Enable | SFINAE condition |
|
inlinestatic |
Serializes data
into j
using the regular nlohmann::adl_serializer
implementation for T
.
Equivalent to:
j | json output |
data | data to serialize |
|
inlinestatic |
Unserializes data
from j
using the regular nlohmann::adl_serializer
implementation for T
.
Equivalent to:
j | json input |
data | data output |