title: How can I generically deserialize PropertyInfo with Json.NET?
body: <p>I need to serialize many different objects with Json.NET. I really have no control over the objects being provided, so I'm generically serializing and de-serializing  with <a href="http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_TypeNameHandling.htm" rel="nofollow">TypeNameHandling.All</a>.</p>
  
  <p>However, some of these objects cannot be de-serialized. Specifically, I am getting some System.Reflection.RuntimePropertyInfo types. I'd like to handle these in a standardized fashion, as I am unaware of the target type at the time of de-serialization. Nor do I care, as long as the output object type is correct.</p>
  
  <p>I've attempted a <a href="http://www.newtonsoft.com/json/help/html/CustomCreationConverter.htm" rel="nofollow">CustomCreationConverter</a> typed to PropertyInfo that is defined in <a href="http://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_JsonSerializerSettings.htm" rel="nofollow">JsonSerializerSettings</a>. However, even though CanConvert() is returning true, the CustomCreationConverter's ReadJson() is never utilized.</p>
  
  <p>The end result is the same as if I had never used the CustomCreationConverter:</p>
  
  <blockquote>
    <p>ISerializable type 'System.Reflection.RuntimePropertyInfo' does not
    have a valid constructor. To correctly implement ISerializable a
    constructor that takes SerializationInfo and StreamingContext
    parameters should be present.</p>
  </blockquote>
  
  <p>I need the CustomCreationConverter to handle the ReadJson so that I can manually search for the PropertyInfo myself.</p>
  
  <p><strong>After more investigation, it appears that the Converters I am adding to the JsonSerializerSettings are not being utilized at all. If I use the DeserializeObject overload that includes the Type and collection of JsonConverter, the Converter will be utilized. I am unsure as to what the Converters supplied to the JsonSerializerSettings are used for, but I would expect they would work as I intend in this situation.</strong></p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Reflection;
  using System.Runtime.Serialization.Formatters;
  using System.Text;
  using System.Threading.Tasks;
  using Newtonsoft.Json;
  using Newtonsoft.Json.Converters;
  using Newtonsoft.Json.Linq;
  
  namespace Json
  {
      class Program
      {
          static void Main(string[] args)
          {
              var jsonSerializerSettings = new JsonSerializerSettings()
              {
                  TypeNameHandling = TypeNameHandling.All,
                  TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple,
                  Converters = new JsonConverter[] { new PropertyInfoConverter(), },
              };
              var propertyInfo = typeof(Test).GetProperty("Name");
  
              var serialized = JsonConvert.SerializeObject(propertyInfo, jsonSerializerSettings);
              var deserialized = JsonConvert.DeserializeObject(serialized, jsonSerializerSettings);
          }
      }
  
      public class Test
      {
          public string Name { get; set; }
      }
  
      public class PropertyInfoConverter : CustomCreationConverter&lt;PropertyInfo&gt;
      {
          public override bool CanConvert(Type objectType)
          {
              return typeof(PropertyInfo).IsAssignableFrom(objectType);
          }
  
          public override PropertyInfo Create(Type objectType)
          {
              return null;
          }
  
          public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
          {
              return null; // This is never invoked, but is where I would attempt to find the PropertyInfo via Reflection searching.
          }
      }
  }
  </code></pre>