Map Json Property With Period To Class Property in Spring Controller

倾然丶 夕夏残阳落幕 提交于 2020-01-06 15:32:10

问题


I have a json object being sent to a controller that maps to a class model. The json contains the property below

"Event.GradeBook.GradeEvent": {  }

How can I represent this in a class model where it will map correctly?

String Event_Gradebook_GradeEvent;

回答1:


Assuming you are using Spring's default Jackson deserialization, all you need to do is annotate your field with @JsonProperty.

@JsonProperty(value = "Event.GradeBook.GradeEvent")
private String Event_Gradebook_GradeEvent;

But you should really follow Java's naming conventions.



来源:https://stackoverflow.com/questions/20646634/map-json-property-with-period-to-class-property-in-spring-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!