Home | Libraries | People | FAQ | More |
There exist many C++ JSON libraries, but two are particularly noteworthy for the purpose of comparison: RapidJSON and JSON for Modern C++ (referred to herein as nlohmann's JSON, or nlohmann).
nlohmann::basic_json
template< template<typename, typename, typename...> class ObjectType, template<typename, typename...> class ArrayType, class StringType, class BooleanType, class NumberIntegerType, class NumberUnsignedType, class NumberFloatType, template<typename> class AllocatorType, template<typename, typename = void> class JSONSerializer > class basic_json { private: .... friend ::nlohmann::detail::parser<basic_json>; friend ::nlohmann::detail::serializer<basic_json>; ...
This library adopts a "kitchen sink" approach. It contains a wealth of features, even those with niche uses. Its weakness is that the many template parameters, while allowing for configurability, inhibit the best possible optimizations. The consequence is that the library performs poorly. The ability to configure every aspect of the value type has the paradoxical effect of making it less suitable as a vocabulary type.
basic_json
is a class template. Libraries must agree on the choices of template parameters
to be interoperable.
BooleanType
anything other than bool
.
basic_json
container declaration
needlessly conflates parsing and serialization APIs.
rapidjson::GenericValue
template <typename Encoding, typename Allocator = MemoryPoolAllocator<> > class GenericValue; template <bool Const, typename ValueT> class GenericArray; template <bool Const, typename ValueT> class GenericObject;
a
= b
is equivalent to a =
std::move(b)
. No
copy construction or copy assignment allowed.
https://github.com/lemire/simdjson
class ParsedJson;
This is quite an interesting data structure, which is optimized to work well with the SIMD parser. It makes very good design choices for the intended use-case. However it is not well suited as a vocabulary type due to the necessary limitations.
ParsedJson::BasicIterator