Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binder does not work when used with Newtonsoft.Json #61

Open
Misiu opened this issue Mar 9, 2022 · 0 comments · May be fixed by #62
Open

Binder does not work when used with Newtonsoft.Json #61

Misiu opened this issue Mar 9, 2022 · 0 comments · May be fixed by #62

Comments

@Misiu
Copy link
Contributor

Misiu commented Mar 9, 2022

I've noticed that after adding HybridModelBinding to my project JsonProperty attributes stopped working.

Below is a very simple controller that allows testing this behaviour:

namespace HybridModelBinding.Samples.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class DataController : ControllerBase
    {
        [HttpPost()]
        public ActionResult<string> GetResCreateponse([FromHybrid]SimpleDto dto)
        {
            return Ok($"Hello {dto.Name} {dto.IsAdmin}");
        }
    }

    public class SimpleDto
    {
        public string Name { get; set; }

        [JsonProperty("is_admin"), JsonPropertyName("is_admin")]
        [HybridBindProperty(Source.Body)]
        public bool IsAdmin  { get; set; }
    }
}

Every time I do a request I get this behavior:
image

When I remove AddHybridModelBinder from Startup everything works as expected.

Does HybridModelBinding work when used with Newtonsoft.Json?
@billbogaiv your feedback is more than welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant