Note: this PR should not be merged before #507 and #511
This PR implements a method in KeyValuePairLogEvent to serialize it into a nlohamnn::json object. KeyValuePairLogEvent, as the output of Deserializer in key-value pair IR format, will be processed by the ffi libraries. Each ffi library has to turn this C++ object into some dynamic data structure in their language. Ideally, KeyValuePairLogEvent can be serialized into msgpack byte sequence. However, there are two problems we need to solve:
In the current format, arrays are stored as an unstructured JSON string. We need to parse the JSON array to build the msgpack array.
It isn't that straightforward to use the official C++ msgpack library to construct an in-memory map and then serialize it into bytes.
Therefore, we decided to serialize KeyValuePairLogEvent into nlohmann::json object instead for now. nlohmann::json provides a better support to construct an in-memory map, and also provides methods to serialize the result into either msgpack byte sequence or JSON string.
With this PR, we should have all the necessary pieces to integrate serialization/deserialization features of the key-value pair IR format into our ffi libraries.
Validation performed
Add unit test to ensure the deserialized KeyValuePairLogEvent can be successfully serialized into nlohmann::json objects, and be identical with the objects before serialization.
Description
Note: this PR should not be merged before #507 and #511 This PR implements a method in
KeyValuePairLogEvent
to serialize it into anlohamnn::json
object.KeyValuePairLogEvent
, as the output ofDeserializer
in key-value pair IR format, will be processed by the ffi libraries. Each ffi library has to turn this C++ object into some dynamic data structure in their language. Ideally,KeyValuePairLogEvent
can be serialized intomsgpack
byte sequence. However, there are two problems we need to solve:msgpack
library to construct an in-memory map and then serialize it into bytes.Therefore, we decided to serialize
KeyValuePairLogEvent
intonlohmann::json
object instead for now.nlohmann::json
provides a better support to construct an in-memory map, and also provides methods to serialize the result into eithermsgpack
byte sequence or JSON string.With this PR, we should have all the necessary pieces to integrate serialization/deserialization features of the key-value pair IR format into our ffi libraries.
Validation performed
KeyValuePairLogEvent
can be successfully serialized intonlohmann::json
objects, and be identical with the objects before serialization.