Skip to content

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

License

Notifications You must be signed in to change notification settings

SimplifyNet/Simplify.Web.Json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 using Newtonsoft.Json.

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 : Controller2
{
    public 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)
{
    ...
    HttpModelHandler.ModelBindersTypes.Clear(); // This is required to remove built-in JSON model binder (based on System.Text.Json)
    DIContainer.Current.RegisterJsonModelBinder();
    ...
}

Accessing model

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

        Model.
    }
}
Synchronous

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

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

Contributing

There are many ways in which you can participate in the project. Like most open-source software projects, contributing code is just one of many outlets where you can help improve. Some of the things that you could help out with are:

  • Documentation (both code and features)
  • Bug reports
  • Bug fixes
  • Feature requests
  • Feature implementations
  • Test coverage
  • Code quality
  • Sample applications

Related Projects

Additional extensions to Simplify.Web live in their own repositories on GitHub. For example:

License

Licensed under the GNU LESSER GENERAL PUBLIC LICENSE

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages