Using NewtonSoft to do the deserializing.
I have the following JSON string
{\"PK\":\"test1@gmail.com\",\"SK\":\"read\",\"Role\":\"RLE#readonly\"}
I want to deserialize it to the following class:
public class UserDto
{
[JsonPropertyName("PK")]
public string Email { get; set; }
public string SK { get; set; }
public string Role { get; set; }
}
When i run the folllowing:
var json = "{\"PK\":\"test1@gmail.com\",\"SK\":\"read\",\"Role\":\"RLE#readonly\"}";
var dto = JsonConvert.DeserializeObject<UserDto>(json);
All properties have values except Email which is null. I have the JsonProperty attribute but its still not working. How do I deserialize the PK JSON property to my Email C# property?