1

Lets say I have a class as follows:

@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

   }
}

When deserializing an API Response to MyClass, is it guaranteed that vertical field is set before unwrapGroupId() is processed???? Else my processing in unwrapGroupId() would fail as this.vertical will be empty. If not , how can it be achieved.

I looked up @JsonPropertyOrder, but looks like it doesnt solve this usecase

Note: I use Jackson 2.8.1

Narayanan P S
  • 111
  • 2
  • 6

0 Answers0