Spring MVC: Doesn't deserialize JSON request body

前端 未结 6 1421
忘掉有多难
忘掉有多难 2020-12-02 09:28

I\'m working on a Spring MVC project and one of the tasks I need to do requires me to have a string of JSON data sent through by the user in a POST request. I know that Spri

6条回答
  •  粉色の甜心
    2020-12-02 09:57

    In my case is because the json has not quoted the field names. An example, this is not accepted:

    { entity: "OneEntity"} 
    

    but this one yes:

    { "entity": "OneEntity"}
    

    I haven't found yet how I can configure object mapping in spring context. I know there is a JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES but I don't know how set that for object mapper.

提交回复
热议问题