Skip to content
master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
src
 
 
 
 
 
 
 
 

Simplify.Web.Json

Nuget Version Nuget Download Build PackageLibraries.io dependency status for latest release CodeFactor Grade Platform PRs Welcome

Simplify.Web.Json is a package which provides JSON serialization/deserialization for Simplify.Web web-framework controllers.

Quick Start

Sending JSON to client

If the controller returns Json response class object, then the Framework execution will be stopped, object will be parsed to JSON string and sent to client

public class MyController : Controller
{
    public override ControllerResponse Invoke()
    {
        ...
        return new Json(myObj);
    }
}

Getting JSON from client

Registering binder

public void Configuration(IApplicationBuilder app)
{
    ...
    HttpModelHandler.RegisterModelBinder<JsonModelBinder>();

    app.UseSimplifyWeb();
}

public void ConfigureServices(IServiceCollection services)
{
    ...
    DIContainer.Current.RegisterJsonModelBinder();
    ...
}

Accessing model

Asynchronous
public class MyController : ControllerAsync<MyModel>
{
    public override async Task<ControllerResponse> Invoke()
    {
        await ReadModelAsync();

        Model.
    }
}
Synchronous

JSON string will be deserialized to the controller model on first model access

public class MyController : Controller<MyModel>
{
    public override ControllerResponse Invoke()
    {
        Model.
    }
}

About

Simplify.Web.Json is a package which provides JSON serialization/deserialization for Simplify.Web web-framework controllers.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages