PS: I got this to work:
template TypedefPolicy(T) if (!is(TypedefType!T == T))
{
TypedefType!T toRepresentation(T t)
{
return cast(TypedefType!T)(t);
}
T fromRepresentation(TypedefType!T v)
{
return T(v);
}
}
unittest
{
import vibe.data.json;
static assert(isPolicySerializable!(TypedefPolicy, QuestionId));
Json serial2 = 42;
QuestionId qi2 = deserializeWithPolicy!(JsonSerializer, TypedefPolicy, QuestionId)(serial2);
}
However I still cannot figure out how to serialize to QuestionAttempts
as in the original post.