[ad_1]
I have a JSON object:
{"id":5,"name":"admin","email":"string","registrationTimestamp":1654196311088,"orderIds":[],"isAdmin":true}
And a Class
public class UserDto
{
public int Id { get; }
public string Name { get; }
public string Email { get; }
public long RegistrationTimestamp { get; }
public int[] OrderIds { get; }
public bool IsAdmin { get; }
}
Using Newtonsoft.Json, I’m trying to deserialize this object:
JsonConvert.DeserializeObject<UserDto>(json);
But it just won’t work, returning not just a null
, but an “empty” object, containing empty strings, zeros for numeric variables and OrdersIds are not set at all.
I really can’t wrap my head around it, would be glad to get a piece of advice. Thanks!
[ad_2]