title: Custom Json Serializer to serialize and deserialize all properties by ignoring the class attributes
body: <p>I want to serialize all properties of my class but want hide some properties while returning response.</p>
  
  <p>I'm using NewtonSoft.Json.Net for serializing.</p>
  
  <p>For example, in below class I want to serialize both properties but I only want to return PlaceName.</p>
  
  <p>Is there any way to do this?</p>
  
  <pre><code>[DataContract]
  public class Place
  {
     [DataMember(EmitDefaultValue = false)]
     public int PlaceId { get; set; }
  
     [DataMember(EmitDefaultValue = false, Order = 1)]
     public string PlaceName { get; set; }
  }
  </code></pre>
  
  <p>EDIT 1:</p>
  
  <p>Below is my current Json File.</p>
  
  <pre><code>[
    {
      "placeId": 1,
      "placeName": "Malacca"
    },
    {
      "placeId": 2,
      "placeName": "Kuala Lumpur"
    },
    {
      "placeId": 3,
      "placeName": "Genting Highlands"
    },
    {
      "placeId": 4,
      "placeName": "Singapore"
    },
    {
      "placeId": 5,
      "placeName": "Penang"
    },
    {
      "placeId": 6,
      "placeName": "Perak"
    },
    {
      "placeId": 8,
      "placeName": "Selangor"
    }
  ]
  </code></pre>
  
  <p>EDIT 2: Found the Solution</p>
  
  <p>I Found the solution with some research.</p>
  
  <p>I've created a custom contract resolver to serialize and deserialize all properties and passed it.</p>
  
  <p>Below is my code</p>
  
  <pre><code>public  class AllPropertiesResolver : DefaultContractResolver
  {
      protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
      {
          JsonProperty property = base.CreateProperty(member, memberSerialization);
          property.Ignored = false;
          return property;
      }
  }
  </code></pre>
  
  <p>And Below is the code where I called it.</p>
  
  <pre><code> JsonConvert.SerializeObject(object, new JsonSerializerSettings() { ContractResolver = new AllPropertiesResolver() });
   JsonConvert.DeserializeObject&lt;T&gt;(stream, new JsonSerializerSettings() { ContractResolver = new AllPropertiesResolver() });
  </code></pre>
  
  <p>Thank you all for responding.</p>