tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Johnny Macnum <>
Subject Dealing with Jettison array serialization issues
Date Wed, 05 Feb 2014 10:54:24 GMT

As described in the CXF document (,
Jettison wrongly serializes List objects by default. The default approach of Jettison is for
me a bad practice.

JSONProvider has two properties 'serializeAsArray'  and 'arrayKeys' to handle this issue.

I think TomEE initializes wrongly the JSONProvider. You should by default set serializeAsArray
to 'true' and allow the developer to configure the list of keys to put in the arrayKeys so
as to produce a well-defined JSON.

 private static List<Object> defaultProviders() {
        final JAXBElementProvider jaxb = new JAXBElementProvider();
        final Map<String, Object> jaxbProperties = new HashMap<String, Object>
        jaxbProperties.put(Marshaller.JAXB_FRAGMENT, true);

        final JSONProvider json = new JSONProvider();
        // TOMEE-514
        // json.setSerializeAsArray(true);

        return Arrays.asList((Object) jaxb, json);

In order to solve my issue, I had to define my customer provider which is quite cumbersome
for a lambda developer.

public class CustomJSONProvider<T> extends JSONProvider<T> {

    public CustomJSONProvider() {
        setArrayKeys(Arrays.asList("element1", "element2"));




  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message