Add subclass matching to serializer field mapping.

First attempt at #1809.
I guess simpler is probably better, but I can't help learning towards more functional styles lately!