Below is my DTO.
public class CustomerTO
{
public int Id { get; set;}
public string Name { get; set;}
//& so on
}
But when I returning the JSON string from my action, I want only few properties to be send to the client.
My Json should look like
{
"id": 1,
"name": "Ram"
}
My Action.
public string GetCustomers()
{
List<CustomerTO> customers = dal.Get();
var strJson = JsonConvert.SerializeObject(customers);
return strJson;
}
Above action returns string as:-
[
{
"id":1,
"name":"Ram",
"age":27,
"Country":"India"
},
{
"id":2,
"name":"Shyam",
"age":27,
"Country":"India"
}
]
How do I filter the properties in JSON from DTO??