I'm having issues deserializating a property w/ JSON.net's DeserializeObject. The JSON is properly formatted and can be extracted using DeserializeObject and accessing the dynamic property, but when I deserialize from my model, the property is always null.
I'm using v10 of JSON.net.
The property in question is defined as such:
[JsonProperty(PropertyName = "email")]
public List<string> EmailAddresses { get; set; }
The Json is below:
"representative" : {
"id" : 16,
"username" : "jb",
"firstName" : "James",
"lastName" : "Bond",
"emailAddress" : "demo@backstopsolutions.com"
},
"email" : [ "test213@example.com", "test312@backstopsolutions.com" ],
"permissionTag" : "Public",
"website" : null,
When I deserialize the object w/ it's type, i.e.
var restResponse = await client.ExecuteTaskAsync<T>(request, cancelToken);
the property is null.
I can do the below, but I'd much prefer to figure out why the deserialization is failing.
dynamic jsonResponse = JsonConvert.DeserializeObject(restResponse.Content);
var tagsJArray = jsonResponse.email as JArray;
if (tagsJArray != null)
{
restResponse.Data.EmailAddresses = tagsJArray.ToObject<List<string>>();
}
I assume I'm missing a JsonProperty attribute, but nothing I've tried has worked. Can anyone help shed some light on this?
Thanks in advance.