<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Serialization &amp;mdash; Attach to Process</title>
    <link>https://devblog.dinobansigan.com/tag:Serialization</link>
    <description>Thoughts and Notes on Software Development</description>
    <pubDate>Mon, 27 Apr 2026 16:46:31 +0000</pubDate>
    <image>
      <url>https://i.snap.as/4wmUdb6N.png</url>
      <title>Serialization &amp;mdash; Attach to Process</title>
      <link>https://devblog.dinobansigan.com/tag:Serialization</link>
    </image>
    <item>
      <title>Conditionally Serializing Fields and Properties with Json.NET | Marius Schulz</title>
      <link>https://devblog.dinobansigan.com/conditionally-serializing-fields-and-properties-with-json-net-marius-schulz?pk_campaign=rss-feed</link>
      <description>&lt;![CDATA[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&#39;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.&#xA;&#xA;  There&#39;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&#39;re serializing, you have to define a public method named ShouldSerialize{MemberName} returning a boolean value.&#xA;Marius Schulz&#xA;&#xA;Visit Original Post: Conditionally Serializing Fields and Properties with Json.NET&#xA;&#xA;It was only after I found Marius&#39; blog post that I then found the documentation talking about conditional property serialization on the Newtonsoft website.&#xA;&#xA;This is one of the rare instances where I didn&#39;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.&#xA;&#xA;#Bookmarks #JsonDotNet #DotNet #Serialization&#xA;&#xA;a href=&#34;https://remark.as/p/devblog.dinobansigan.com/conditionally-serializing-fields-and-properties-with-json-net-marius-schulz&#34;Discuss.../a or leave a comment below.]]&gt;</description>
      <content:encoded><![CDATA[<p>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 <code>[JsonIgnore]</code> 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&#39;s value during deserialization. Thankfully I found a <a href="https://mariusschulz.com/blog/conditionally-serializing-fields-and-properties-with-jsonnet">blog post</a> 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.</p>

<blockquote><p>There&#39;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&#39;re serializing, you have to define a public method named ShouldSerialize{MemberName} returning a boolean value.
– Marius Schulz</p></blockquote>

<p>Visit Original Post: <a href="https://mariusschulz.com/blog/conditionally-serializing-fields-and-properties-with-jsonnet">Conditionally Serializing Fields and Properties with Json.NET</a></p>

<p>It was only after I found Marius&#39; blog post that I then found the documentation talking about <a href="https://www.newtonsoft.com/json/help/html/ConditionalProperties.htm">conditional property serialization</a> on the Newtonsoft website.</p>

<p><em>This is one of the rare instances where I didn&#39;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.</em></p>

<p><a href="https://devblog.dinobansigan.com/tag:Bookmarks" class="hashtag"><span>#</span><span class="p-category">Bookmarks</span></a> <a href="https://devblog.dinobansigan.com/tag:JsonDotNet" class="hashtag"><span>#</span><span class="p-category">JsonDotNet</span></a> <a href="https://devblog.dinobansigan.com/tag:DotNet" class="hashtag"><span>#</span><span class="p-category">DotNet</span></a> <a href="https://devblog.dinobansigan.com/tag:Serialization" class="hashtag"><span>#</span><span class="p-category">Serialization</span></a></p>

<p><strong><a href="https://remark.as/p/devblog.dinobansigan.com/conditionally-serializing-fields-and-properties-with-json-net-marius-schulz">Discuss...</a></strong> or leave a comment below.</p>
]]></content:encoded>
      <guid>https://devblog.dinobansigan.com/conditionally-serializing-fields-and-properties-with-json-net-marius-schulz</guid>
      <pubDate>Fri, 25 Jan 2019 00:00:00 +0000</pubDate>
    </item>
  </channel>
</rss>