This project has moved and is read-only. For the latest updates, please go here.

Choosing which properties to include at runtime...

Oct 22, 2009 at 5:20 AM

Hi guys

I have a case where I have an collection of objects that has about 20 properties each... When this is serialized, unless I am using some sort of ignore attribute, all 20 properties get serialized.

What I would like to go is allow the client to pass back which columns it needs and for those to be the only ones to be serialized. This would allow me to use the same business object, and use it in different places where sometimes I only need 2 properties and other times I need another 6...

Can I do this with Json.NET and if so how would I do this?




Oct 24, 2009 at 2:30 AM

Either create a JsonConverter and read and write the JSON manually or use a IContractResolver. There is an example in this blog post -

Aug 20, 2010 at 4:41 PM


We recently started using this library and appreciate what it can do.  But, would love to see a simple JsonIgnore attribute (akin to XmlIgnore) that would allow us to specify properties that can be safely ignored.