If the JSON string does not conform to the specification, it can be resolved by customizing the JsonConvert
public class SingleValueArrayConverter<T> : JsonConverter { public override void Writejson (Jsonwriter writer, object value, jsonserializer serializer) { Throw new notimplementedexception (); } public override object readjson (JsonReader Reader, type objecttype, object existingvalue, jsonserializer serializer) { object retval = new object (); if (reader. TOkentype == jsontoken.startobject) { T instance = (T) serializer. Deserialize (reader, typeof (T)); retVal = new List<T> () { instance }; } else if (reader. Tokentype == jsontoken.startarray) { retval = serializer. Deserialize (reader, objecttype); } return retval; } public override bool Canconvert (Type objecttype) { return true; } }
Custom Jsonconverter, deserializing array properties that do not conform to the specification