I've written an ASP.Net web API, my requirement to show the full/some result (s) JSON based on the parameter i.e., verbose=true
To Explain this requirements.
My current JSON is
Without verbose
GET Method:
api/v1/patient?Key=1
{
"user": {
"key": 1,
"suffix": "1",
"firstName": "Dhanu",
"lastName": "Kumar",
"middleName": "",
"address": {
"address1": "uuu",
"address2": "TTT",
"address3": "xx",
"city": "yy"
}
}
}
With verbose
api/v1/patient?Key=1&verbose=true
{
"user": {
"key": 1,
"firstName": "Dhanu",
"lastName": "Kumar",
"middleName": ""
}
}
My User.cs
public UserDTO()
{
public int Key { get; set; }
public string Suffix { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string MiddleName { get; set; }
public Address Address {get;set;}
}
Based on the verbose parameter, I'll Hide/Show some fields from the JSON.
Is there any way to achieve this?