Set a max depth when deserializing into specific type.

#1484