I'm using Jackson within CXF to serialize/deserialize data. Unfortunately, I am having difficulty configuring CXF/Jackson to deserialize a JSON array. I'd appreciate help in resolving the issue.
Up to this point most of the json data has been in object format, i.e.
{ "objectCollection": [ {...}, {...}, {...}... ] }
However, the json data in question is of the form:
[ {...}, {...}, {...} ]
The web service endpoint expects a "GroupsDto" object (see following) that has a single property -- a collection of groups, which is transmitted via the JSON array.
@PATH(...)
public Response createGroups(GroupsDto groups) {
...
}
I added @JsonDeserialize as follows to the GroupsDto collection property, but it does NOT work. I continue to get: "Can not deserialize instance of GroupsDto out of START_ARRAY token"
public class GroupsDto {
private Collection<GroupDto> groups;
/**
* @return the groups
*/
@XmlElement(name="group")
@JsonDeserialize(contentAs=GroupDto.class)
public Collection<GroupDto> getGroups() {
return groups;
}
...
}