encode_traits.md

August 6, 2026 ยท View on GitHub

jsoncons::reflect::encode_traits

#include <jsoncons/reflect/encode_traits.hpp>

encode_traits define a compile time template based interface for converting a C++ data structure into a character buffer or an output stream. They are used in the encode_<format> functions such as encode_json.

template <typename T, typename Enable = void>
struct encode_traits
{
public:
    template <typename CharT, typename Alloc, typename TempAlloc>
    static write_result encode(const allocator_set<Alloc,TempAlloc>& aset,
        const T& val, 
        basic_json_visitor<CharT>& encoder);
};