问题
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