Following up on my last question (http://stackoverflow.com/questions/8027748/render-c-sharp-class-as-javascript/8027824#8027824), I'm now using JSON.net to convert some classes to JSON. Works great, but I have some class which contain other classes as members. For instance:
public class Parent
{
public Child Child { get; set; }
public string Var { get; set; }
}
When I render this using json.net, I can set the serializer to ignore nulls. This means the Var member isn't printed when it hasn't been set. I'd like the same behaviour for the Child member, based upon it's values. So when all members of Child are null, the entire class renders as "{}" and it should be ignored in the parent object alltogether.
Is this possible?