On Fri, 04 Nov 2016 11:51:39 GMT, Saurabh Das wrote:

Okay, sorry for posting so frequently. I've got it to work in 2 steps: by first converting it to a Json and then to the required struct:

    auto serialStr1 = "{\"studentId\":300453,\"questionId\":65708,\"questionRevision\":1,\"action\":\"correct\",\"timeTakenSeconds\":10,\"eventTimestamp\":\"2016-01-01T00:00:03\",\"metadata\":\"\",\"frontend\":\"\"}";
    auto j4 = parseJsonString(serialStr1);
    writeln(j4);
    auto ss4 = deserializeWithPolicy!(JsonSerializer, TypedefPolicy, QuestionAttempts)(j4);
    writeln(ss4);

Is this the idiomatic way to accomplish this task?

Did you try with deserializeWithPolicy!(JsonStringSeriailzer, TypedefPolicy, QuestionAttempts)(serialStr1)? That would avoid the dynamic memory allocations that are required for first converting to Json. Policy based serialization is still missing some convenience overloads, but I think there should be a version of deserializeJson that directly accepts a policy.

Also, if I'm making a REST interface using registerRestInterface, how can I pass tell registerRestInterface to use my custom policy?

Unfortunately this is not yet possible. It's planned to be added in conjunction with general support for custom serialization. Related issues: #1569, #1040, #1467

Thanks,
Sorry again for making you read all the above posts uselessly.

No problem at all! I know that all this serialization policy topic is not really well documented, yet.