Deserialize JSON when a value can be an object or an empty array

You could make a JsonConverter like the following, that looks for either an object of a specified type, or an empty array. If an object, it deserializes that object. If an empty array, it returns null: public class JsonSingleOrEmptyArrayConverter<T> : JsonConverter where T : class { public override bool CanConvert(Type objectType) { return typeof(T).IsAssignableFrom(objectType); } … Read more