Mine is a .net core web api which returns user details: I have a model class like this :
public class UserDetails
{
[JsonProperty("name")]
[Display(Name = "First Name")]
public string FirstName { get; set; }
[JsonProperty("lastName")]
public string LastName { get; set; }
[JsonProperty("designation")]
public string Designation { get; set; }
}
I have an method in Data base Layer which fetches some user details from Mongo and de-serializes the json and casts into UserDetails
type.
When I see the response of the end point in postman , I see it like this :
> {
> "name": "ABC",
> "LastName": "XYZ",
> "designation": "team Lead"
> }
The Display Name which I mentioned as annotation on top of the property is not working.
How can I make my code return First Name instead of "name". Many thanks for all the answers.