Hi Anthony
I'm CC-ing to the users list because it can be of interest to others.
On 30/01/15 09:35, MULLER, Anthony wrote:
Hello Sergey,
About this issue:
http://jira.codehaus.org/browse/JETTISON-142
Do you think this will help to troubleshoot the array serialization issue with
Jettison?
Not really. JETTISON-142 patch provides a fairly specific work-around
which works only in JSON->XML->JSON auto conversion cases. The challenge
there is to investigate if JSON-> XML or JAXB Bean -> JSON can also
work. Most likely it is not related to the issues you are seeing
In our case, customers provide us several times the same feedback about the
difficulty to handle the JSON output:
1) when no element in an array, we get: reports: ""
--> they'd like: reports : [] or reports : null
2) when there is only one element, we get reports: {report: {name = "foo"}}
--> they'd like: reports: {[report: {name = "foo"}]}
We already know about some existing settings in Jettison (serializedAsArray
flag and this other parameter to provide tag names to deal with), but it is not
flexible enough for us because we have some cases when a tag is effectively in
an array, and another XML document where the same tag name is not in an array...
Jettison 1.3.6 introduces namespace-'local' array keys. For example,
'n1.a', 'n2.b', where 'n1' and 'n2' are namespace prefixes registered in
a separate namespace map.
So, if you have a single JSONProvider handling multiple documents where
an element with a name 'a' is a list in not all of the documents then
most likely you can use something like 'n1.a', etc, to uniquely identify
such a property.
I hope migrating to Jettison 1.3.6 can help. Let me know please
Indeed, Jackson would offer a more robust alternative but you'd need to
annotate the given beans with Jackson annotations...
HTH, Sergey
I'm looking forward to get your point of view.
Best regards,
Anthony