Custom Json.NET contract resolver for lowercase underscore to CamelCase

前端 未结 1 1151
悲&欢浪女
悲&欢浪女 2021-02-20 15:43

I\'m working on a REST API in ASP.NET MVC where the resulting serialised JSON uses lowercase_underscore for attributes.

From a class Person with string prop

相关标签:
1条回答
  • 2021-02-20 16:35

    OK, found the solution. I was missing a default constructor for the Person class. Once I did that, the mapping worked when calling the Put method. In fact, I could also remove the FromBody specifier:

    public object Put(int id, Person person)
    
    0 讨论(0)
提交回复
热议问题