Hello everybody,
First sorry if this topic is not for this forum, I'm searching answers and I might be in the wrong forum / thread.
I have a stranger issue with moxy version 2.5.2. In short let's see the following two cases:
Here are some samples from the json I have.
1. Case one, we have a valid JSON object with one property which is an array
.....
"propertyValue": {
"@scheme.type": "rbi.RbiRatingsPropertyValueVo",
"ratings": [
"rating-1",
"rating-2"
]
}
.....
We unmarshall this json successfully, but the collection named ratings is empty. While debugging I saw that for this collection is created a CollectionGroupingNodeValue.
2. Here is another case with almost the same JSON:
.....
"propertyValue": {
"@scheme.type": "rbi.RbiRatingsPropertyValueVo",
"name": "ratingsNode-1",
"ratings": [
"rating-1",
"rating-2"
]
}
.....
In this case when we unmarshall this JSON we have correct object with a collection which has the 2 items in it, when debugging I saw that now I have XmlCompositeDirectollectionMappingNodeValue which is handling the ratings array.
The problem is that we have the first JSON and we want to deserialize it correctly, but the ratings colelctions comes empty.
Does any one have an idea how can we fix this issue, i tried with the latest moxy version but the result was the same.
Here are the JAXB annotations if this can help:
@XmlRootElement(name = "RbiRatingsPropertyValueVo", namespace = "some.domain/rbi")
@XmlType(name = "RbiRatingsPropertyValueVo", namespace = "some.domain/rbi")
@XmlAccessorType(XmlAccessType.FIELD)
public class RbiRatingsPropertyValueVo extends RbiPropertyValueVo {
private static final long serialVersionUID = 1L;
// This property is for the second case to show the difference, actually it doesn't exist here
@XmlElement(name = "name")
private String name;
@XmlElement(name = "String", type = String.class)
@XmlElementWrapper(name = "ratings")
private List<String> ratings = new ArrayList<>();
......
// Plus default ctor, explicit, setetrs and getetrs
}
Thank you and have a nice day.
PS: when marshalling and unmarshalling with JAXB (only to and from XML) the results is as expected, the ratings collection is not empty after deserializing.