I am working on deserializing the below JSON:
{"self":"http://members.cs.com/rest/api/user?username=abc@cs.com",
"key":"abc@cs.com",
"name":"abc@cs.com",
"emailAddress":"abc@cs.com",
"displayName":"ABC",
"active":true,
"members":{"size":1,"items":[{"name":"member-users","self":"http://members.cs.com/rest/api/user?username=abc@cs.com"}]},
"expand":"members"}
I have created the following classes:
@JsonIgnoreProperties(ignoreUnknown = true)
public class UserList {
private String name;
private String emailAddress;
private String displayName;
private boolean active;
List<MemberName> members = new ArrayList<>();
@JsonCreator
public UserList(@JsonProperty("name") String name, @JsonProperty("emailAddress") String emailAddress, @JsonProperty("displayName") String displayName, @JsonProperty("active") boolean active, @JsonProperty("members") List<MemberName> members) {
this.name = name;
this.emailAddress = emailAddress;
this.displayName = displayName;
this.active = active;
this.members.addAll(groups);
}
//getters
}
@JsonIgnoreProperties(ignoreUnknown = true)
public class MemberName {
private String name;
@JsonCreator
public MemberName(@JsonProperty("name") String name) {
this.name = name;
}
public String getName() {
return name;
}
}
When I don't give the members as a property the deserialization works fine and I can see the values for the name, displayName, active, emailAddress. The problem happens with the MemberName.
Could someone help with this?