title: How do I deserialize an array of enum using Json.Net?
body: <p>I have a JSON like this:</p>
  
  <pre><code>[{ 
      "agencyId": "myCity",
      "road": {
      "note": "",
          "lat": "45.321",
          "lon": "12.21",
          "streetCode": "290",
          "street": "street1",
          "fromNumber": "",
          "toNumber": "",
          "fromIntersection": "",
          "toIntersection": ""
      },
      "changeTypes": ["PARKING_BLOCK", "ROAD_BLOCK"],
  },]
  </code></pre>
  
  <p>and a class like this:</p>
  
  <pre><code>public class AlertRoad : BaseAlert
  {
      [JsonProperty("agencyId")]
      [JsonConverter(typeof(StringEnumConverter))]
      public AgencyType AgencyId { get; set; }
  
      [JsonProperty("changeTypes")]
      [JsonConverter(typeof(StringEnumConverter))]
      public ChangeType[] ChangeTypes { get; set; }
  
      [JsonProperty("road")]
      public Road RoadInfo { get; set; }
  }
  </code></pre>
  
  <p>AgencyType is an enumeration, and deserializiation and serialization for AgencyId works.</p>
  
  <p>ChangeType is another enumeration, but deserializiation and serialization for ChangeTypes doesn't work.
  I assume the reason is that ChangeTypes is an array of enumeration values.</p>
  
  <p>The question is: how can I deserialize/serialize ChangeTypes field, or in general an array of enumeration values?</p>
  
  <p>I tried by defining my own field converter, called ChangeTypeConverter, and changing StrinEnumConverter to ChangeTypeConverter for ChangeTypes field, but in the ReadJson function the value of reader is null.</p>
  
  <pre><code>public class ChangeTypeConverter : JsonConverter
  {
      public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
      {
  
      }
  
      public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
      {
          var val = reader.Value;
          //val is null?!?
          return val;
      }
  
      public override bool CanConvert(Type objectType)
      {
          return objectType == typeof(ChangeType);
      }
  }
  </code></pre>