Hi, I got a class, something like:
@XmlRootElement(name="myClass")
class MyClass {
public List<Article> related = new ArrayList<Article>();
}
@XmlRootElement(name="Article")
class Article {
public String title;
}
now, if I try to use JAXB to serialize this object, I get :
{myClass : { related: { 'title' : "some title" }}
If the related field contains one article and
{myClass : { related: [{ 'title' : "some title" }, { 'title' : "some
title" }]}
if there are two or more. Notice the [] around the related items.
Now, this is more than a bit annoying - it is very inconsistent and IMHO
illogical - you cannot depend on the representation being close to
correct across various datasets. Also it becomes a big problem when
dealing with languages like PHP that do not differ between a Hash and a
List which makes it very hard to detect the difference and handle it.
So, what should I do?
Regards,
Tarjei