Skip to content

egorpavlikhin/JsonParametersModelBinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NuGet

JsonParametersModelBinder

Allows you to map JSON object directly to controller action parameters. Convert JSON model

{ "a": "a", "b": { "c": "value" } }

directly to action method

public ... Method(string a, dynamic b)

Warning

Nested objects are supported as dynamic types (with limitations).

Usage

Step 1. Add attribute JsonParameters to your action

[HttpPost("two")]
[JsonParameters]
public async Task<IActionResult> TwoParameters(string a, dynamic b)
{
    Console.WriteLine(b.c);
    return Ok();
}

Step 2. Enhoy simplified workflow.

Thanks

Thanks to tchivs for providing code to map to dynamic types

About

Map JSON object directly to controller action parameters

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages