Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not knowing a type before deserializing

Is it possible to deserialize (c#) a piece of xml, csv, json (whatever it is), and not know it's type? But be given back an object (which ultimately is the correct type)?

like image 821
Paul Avatar asked Jun 10 '10 17:06

Paul


1 Answers

Yes, it is possible.

The serialized XML/CSV/JSON data must contain identifiers to allow the deserializer to know what types of objects to create, since this can't be known beforehand. So that the deserializer can construct new object instances, the FactoryMethod design pattern is usually employed.

Deserialization is harder than serialization.

like image 132
bbudge Avatar answered Oct 13 '22 20:10

bbudge