Attach to Process

Bookmarks

Recently I ran into an issue where I needed to exclude a property from getting serialized using Json.NET. The easy answer is to add a [JsonIgnore] attribute to the property. The problem with doing that is it will also ignore the same property during deserialization. So I needed a solution that allows me to ignore a property using serialization, but still set that property's value during deserialization. Thankfully I found a blog post from 2013 that explains exactly how to do that. I would have wasted more hours searching for an answer had I not found this solution right away.

There's a little known feature of Json.NET that lets you determine at runtime whether or not to serialize a particular object member: On the object you're serializing, you have to define a public method named ShouldSerialize{MemberName} returning a boolean value. – Marius Schulz

Visit Original Post: Conditionally Serializing Fields and Properties with Json.NET

It was only after I found Marius' blog post that I then found the documentation talking about conditional property serialization on the Newtonsoft website.

This is one of the rare instances where I didn't find the answer in StackOverflow. It makes me grateful for the developers who are still cranking out blog posts and sharing solutions to problems on their personal blogs/websites.

#Bookmarks #JsonDotNet #DotNet #Serialization

Discuss... or leave a comment below.

Out of the 5 SOLID principles, the Open/Closed principle was the hardest one for me to grasp. This post from Code Maze explains it really well and the code examples were very helpful. This was a good read.

Link: Open and Closed Principle

Rather than writing my own post about it, I thought I would share this one instead. After all, as programmers we should avoid reinventing the wheel as much as possible. This is also my first post in a new “Bookmarks” category that I've added to this website. The plan is to use that new post category to share interesting articles that I've found online.

#Bookmarks #SolidPrinciples #CSharp

Discuss... or leave a comment below.