.Net Core - Set JsonApiSerializer as Default Setting
See original GitHub issueHello Everyone!!
I am really appreciating this library. Great Job. Maybe this is not the right place to ask, but I really dont know.
I am trying to get a global configuration using .NET CORE 2 MVC API.
I can easily convert an object using this code. This is a controller and I am converting and respond using Ok(Json).
public IActionResult Get([FromRoute]string company)
{
var parts = _partService.GetAll(company);
string json = JsonConvert.SerializeObject(parts, new JsonApiSerializerSettings());
return Ok(json);
}
. It Works, but add some backslashes to the JSON due to the duplicate serialization, from the JsonConvert and then from the MVC.
"{\"data\":[{\"type\":\"partdefinitionapimodel\",\"id\":\"2026001632590498180\",\"attributes\":{\"name\":\"Tax
I Tried to look over the internet and could not find any place where I could change globally the JsonSerializerSettings with NET CORE.
I am thinking there is something related to services.AddMvc().AddJsonOption inside Startup class but I really dont know where to look or how to do it.
Thanks in advance for any help!!
Issue Analytics
- State:
- Created 6 years ago
- Comments:7
Although closed you can achieve something similiar with less lines by going
Does Anyone knows how to setup JsonApiSerializer as the default input serializer on .NET 3.1? No matter how hard I try, I can’t get the objects of my Binding Model to be different from null when sending a JsonApi formatted object.
Thanks