Mvc Controller filter to retrieve only requested json elements of a given resource. It uses JsonMask.NET.
$ dotnet add package JsonMask.NET.AspNetCore.Mvc.Controller.FilterThis ASP.NET Core MVC filter empowers developers to selectively retrieve specific JSON elements from a resource's response. Built on the robust capabilities of JsonMask.NET, this library offers a streamlined and efficient approach to manipulating JSON responses. By leveraging query parameters, developers can easily tailor the JSON output, ensuring that clients receive only the data they need. This not only enhances the flexibility of API responses but also optimizes data transfer and processing, making it an ideal solution for scenarios where bandwidth and processing efficiency are crucial.
Install JsonMask.NET.AspNetCore.Mvc.Controller.Filter via NuGet:
Install-Package JsonMask.NET.AspNetCore.Mvc.Controller.Filter -Version [Version]
Replace [Version] with the desired version number.
In your Startup.cs, register the necessary services and filters:
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddJsonMask();
// ...
}
If you are using Swagger, add the JsonMaskedSwaggerFilter to your Swagger configuration:
public void ConfigureServices(IServiceCollection services)
{
// ...
services.AddSwaggerGen(options =>
{
options.OperationFilter<JsonMaskedSwaggerFilter>();
});
// ...
}
Apply the JsonMasked attribute at the action level:
[JsonMasked]
public IActionResult MyAction()
{
// Your action logic here
}
For more detailed information on usage and syntax, please refer to the JsonMask.NET documentation.
Contributions to JsonMask.NET.AspNetCore.Mvc.Controller.Filter are welcome. Please read our contributing guidelines for details on submitting pull requests.
This project is licensed under the MIT License - see the LICENSE.md file for details.