I'm having a problem related with the Json response. Here's a example of the response:
public class ContentModel
{
public int? Total { get; set; }
public IEnumerable<ContentResultModel> Results { get; set; }
public FullContentModel Result { get; set; }
public IEnumerable<PaginationModel> Pagination { get; set; }
public IEnumerable<ContentCommentsModel> Comments { get; set; }
}
I don't want the pagination to come in the response, if its empty. For example, for when it's null, I use:
options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
Is there anything similar, that could solve my problem? I already search, and almost everybody uses a regex expression, but I want to avoid that, and want to use something more straightforward and simple, if its possible.
Even if I say the pagination property is null, it always changes to empty. Thanks.