Question background:
I am receiving a JSON response via a HttpResponseMessage, as shown:
var jsonString= response.Content.ReadAsStringAsync().Result;
This is giving me the following simple escaped JSON string result:
"\"{\\\"A\\\":\\\"B\\\"}\""
The problem:
I am using Newtonsoft to try and deserialize this to a model:
SimpleModel simpleModel= JsonConvert.DeserializeObject<SimpleModel>(jsonString);
The Class model of SimpleModel:
public class SimpleModel
{
public string A { set; get; }
}
The conversion is giving me the following error:
An exception of type 'Newtonsoft.Json.JsonSerializationException' occurred in Newtonsoft.Json.dll but was not handled in user code
Additional information: Error converting value "{"A":"B"}" to type 'PyeWebClient.Tests.ModelConversionTests+SimpleModel'. Path '', line 1, position 15.
The JSON I receive back from the Task Result is valid, so I cannot understand what the problem is to cause the conversion error, what is the correct way to format the JSON string so it can be converted to its C# model type?

