Skip to content
Discussion options

You must be logged in to vote

For your sample class, the TPL_ macro,

JSONCONS_TPL_ALL_GETTER_SETTER_TRAITS(1, Foo, , , bar)

will generate a corresponding json_conv_traits specialization, which you can also provide yourself as

namespace jsoncons {
namespace reflect {

template <typename Json, typename T1 >
struct json_conv_traits<Json, Foo < T1 >>
{
    using value_type = Foo < T1 >;
    using result_type = conversion_result<value_type>;

    static bool is(const Json& j) noexcept
    {
        if (!j.is_object()) return false;
        if (!j.contains("bar")) return false;
        return true;
    }

    template <typename Alloc, typename TempAlloc>
    static result_type try_as(const allocator_set<Alloc, TempAlloc>& a…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by janucaria
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants