Properly typecast attributes before serializing.