One of the least explored feature of Newtonsoft Json is the ability serialize properties conditionally. Consider the hypothetical situation wherein you want to serialize a property in a class only if a condition is satisfied. For example, If the requirement is that you need to include serialize the Department Property only if the User Is … Continue reading Conditional Serialization using NewtonSoft Json
Sometimes you run into things that might look trivial but it just do not work as expected. One such example is when you attempt to serialize/Deserialize a Dictionary with Tuples as the key. For example The above code would trow an JsonSerializationException when deserializing. But the good part is, the exception tells you exactly what … Continue reading Serializing/Deserializing Dictionaries with Tuple as Key
Protobuf-net is a .net adaption of Google's Protocol Buffers and is generally considered to be a really fast serialization/deserialization library. The target serializable classes are decorated with mainly 3 attributes. ProtoContract The target class is decorated with the ProtoContract attributes, indicating that the class can be serialized. ProtoMember(N) The ProtoMember attribute indicates the field that … Continue reading Quick Intro to Protobuf
Don't ask me why one cannot Serialize/Deserialize a NameValueCollection, but the workaround for the same is based on conversion to dictionary. I ended up writing extension methods to NameValueCollection for serializing and deserializing the collection.