Вынужден использовать DataContractJsonSerializer
такой json
{"ErrorMessage":""}
класс
[DataContract]
public class ResultScanResponse
{
[DataMember(Name = "ErrorMessage")]
public string ErrorMessage { get; set; }
}
код
public static T Deserialize<T>(string aJSON) where T : new()
{
T deserializedObj = new T();
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(aJSON));
DataContractJsonSerializer ser = new DataContractJsonSerializer(aJSON.GetType());
deserializedObj = (T)ser.ReadObject(ms);
ms.Close();
return deserializedObj;
}
при десериализации пишет
"There was an error deserializing the object of type System.String. End element 'root' from namespace '' expected. Found element 'ErrorMessage' from namespace ''."
Что ему не так?