BitSerializer / JSON (based on C++ REST SDK)
Supported load/save JSON from:
- std::string: UTF-8
- std::stream: UTF-8 (with/without BOM)
This implementation of JSON archive is based on C++ REST SDK - one of most powerful library for work with HTTP.
The recommended way is to use one of supported package managers, but you can do it manually just via CMake commands (in this case you should take care of the dependencies yourself).
Add BitSerializer to manifest file (vcpkg.json) with cpprestjson-archive feature:
{
"dependencies": [
{
"name": "bitserializer",
"features": [ "cpprestjson-archive" ]
}
]
}If your project is based on VS solution you can just include next header files for start use:
#include "bitserializer/bit_serializer.h"
#include "bitserializer/cpprestjson_archive.h"If you are using CMake, you need to link the library:
find_package(bitserializer CONFIG REQUIRED)
target_link_libraries(main PRIVATE BitSerializer::cpprestjson-archive)Add the BitSerializer recipe to conanfile.txt in your project and enable with_cpprestsdk option:
[requires]
bitserializer/0.65
[options]
bitserializer:with_cpprestsdk=True
The dependent library CppRestSdk will be automatically installed.
Usage the library will be related to selected Conan generator, if your choice is cmake_find_package_multi, than linking will be classic:
find_package(bitserializer CONFIG REQUIRED)
target_link_libraries(main PRIVATE BitSerializer::cpprestjson-archive)One of the important things related to JSON implementations in CppRestSdk is character dimension on different platforms - for Windows it's 16-bit (UTF-16), for all other - 8-bit char (UTF-8). In any case, BitSerializer adapts the key to the target archive, but this may affect the performance.
The JSON specification allows to store on root not just objects and arrays, but also more primitive types such as string, number and boolean. The BitSerializer also supports this abilities, have a look to Hello world example.