让我们说我的课如下:
@JsonIgnoreProperties(ignoreUnknown = true)
class MyClass {
@JsonProperty(value="vertical")
private String vertical;
private String groupId;
@JsonProperty(value = "relationships")
private void unwrapGroupId(Map<String, Map<String, List<Map<String, Object>>>> relationships) {
this.groupId = ""; // Some logic to process the relationships map & set this.groupId based on the value set in this.vertical during deserialization
}
}
反序列化对MyClass的API响应时,是否可以确保在处理unwrapGroupId()之前设置了垂直字段?否则我在unwrapGroupId()中的处理将失败,因为this.vertical将为空。如果没有,那么如何实现。
我查找了@JsonPropertyOrder,但看起来无法解决此用例
注意:我使用的是Jackson 2.8.1