YouZack.FromJsonBody NuGet Package

# YouZack.FromJsonBody
Bind simple parameter of Action with HttpBody of Json format.
For ASP.Net Core MVC and ASP.Net Core WebAPI

···
public async Task<IActionResult> Test([FromJsonBody]string phoneNumber, [FromJsonBody]string test1,
[FromJsonBody]int? age, [FromJsonBody] bool gender, [FromJsonBody] double salary);
···

Http Body:
{"phoneNumber":"110112119","age":18,"gender":true}

and ContentType of request should be application/json

Add following code to Startup before app.UseEndpoints():
···
app.UseFromJsonBody();//using YouZack.FromJsonBody;
···

Done!

To KEEP IT SIMPLE, YouZack.FromJsonBody only supports simple parameter types,like int,long,double,bool,Enum,string ,but does not support complex types,like Array,List,POCO etc.
If you want to use complex types, please go backwards to '[FromBody]' and ModelBinder.




Got any YouZack.FromJsonBody Question?





Info

Version: 1.1.1
Author(s): YouZack
Last Update: Tuesday, March 2, 2021
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/yangzhongke/YouZack.FromJsonBody
NuGet Url: https://www.nuget.org/packages/YouZack.FromJsonBody


Install
Install-Package YouZack.FromJsonBody
dotnet add package YouZack.FromJsonBody
paket add YouZack.FromJsonBody
YouZack.FromJsonBody Download (Unzip the "nupkg" after downloading)





STATS

must-have-score

2.8

avg-downloads-per-day

1

days-since-last-release

1362