From 1970145b902551ffdaef21870a75aa9bd889e6a9 Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 29 Jun 2020 20:59:01 +0200 Subject: [PATCH] Add documentation regarding direct RapidJSON usage --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 29b926f..670add3 100644 --- a/README.md +++ b/README.md @@ -98,6 +98,7 @@ The following table shows the mapping of supported C++ types to supported JSON t * The binary (de)serializer supports approximately the same C++ types but obviously maps them to a platform independent binary representation rather than a JSON type. + ## Usage This example shows how the library can be used to make a `struct` serializable:
@@ -143,6 +144,22 @@ There are further arguments available, see:
 reflective_rapidjson_generator --help
 
+### Mixing with direct RapidJSON usage and further notes +It is of course possible to mix automatic serialization/deserialization with direct RapidJSON usage. This can be +done by invoking the `push` and `pull` functions within the `ReflectiveRapidJSON::JsonReflector` namespace directly. + +The `push` functions are used on serialization to populate intermediate data structures for the serializer of the +RapidJSON library. The intermediate JSON document can also easily be obtained via +`JsonSerializable::toJsonDocument()`. + +Note that this means a copy of the provided data will be made. That includes all strings as well. Currently there +is no way to use RapidJSON's copy-free `SetString`-overloads instead. As a consequence the mentioned intermediate +JSON document can be serialized without causing any further read accesses to the actual data structures. + +The `pull` functions are used to populate your data structures from intermediate data structures produced by the +parser of RapidJSON. Also in this case a copy will be made so only owning data structures can be used when +deserializing (see remarks regarding supported datatypes). + #### Binary (de)serialization It works very similar to the example above. Just use the `BinarySerializable` class instead (or in addition):