title: Can I tell the WCF WebAPI serializer to ignore nested class objects?
body: <p>I am using <a href="http://wcf.codeplex.com" rel="nofollow noreferrer">WCF WebAPI</a> to write REST services using WCF.
  I am returning my POCO classes as json/xml objects from my service. 
  Most of my POCO classes contain <code>ICollection</code>s as they are part of EF4.1 Code First, 
  hence I get error :</p>
  
  <blockquote>
    <p>Cannot serialize member of type ...
    System.Collections.Generic.ICollection ... because it is of type -
    because it is an interface</p>
  </blockquote>
  
  <p>To avoid that <code>XMLIgnore</code> and <code>ScriptIgnore</code> is <a href="https://stackoverflow.com/questions/1411577/ignoring-a-field-during-net-json-serialization-similar-to-xmlignore">suggested</a>.  And there are some problems in <a href="https://stackoverflow.com/questions/1174486/what-could-be-the-reason-that-my-custom-rest-serializer-is-not-working">custom serialization of JSON in WCF</a>.</p>
  
  <p>Just thought someone might have come across a similar problem and have a better solution or way to configure serialization classes, otherwise I will have to decorate each such attribute with <code>XMLIgnore</code>, etc.</p>