Hi,

When I execute the GET serviceGroup Stratos endpoint I get the folowing
output in two different groups. Please note cartridges text  in bold. When
there are only one cartridge, it shows as a String (output1), when there
are multiple cartridges it is shown as an array (output2).

But when I convert the object to a json text, it shows as arrays even when
there are single cartridge.

The issue happens when the object is sent in response as below

return Response.ok().entity(serviceGroupDefinition).build();


In the code carridges is set as a list.


   1. List<String> cartridgesDef = new ArrayList<String>(Arrays.asList(
   cartridges));
   2. servicegroupDef.setCartridges(cartridgesDef);


[1] suggested to set serializeAsArray as true in cxf-servlet.xml.xml, I
tried doing it too. But same result.

What is the reason for this?


output [1]

{
    "serviceGroup": [
        {
           * "cartridges": "tomcat",*
            "dependencies": {
                "startupOrders": "group.group1,cartridge.tomcat",
                "terminationBehaviour": "terminate-dependents"
            },
            "name": "group5",
            "subGroups": "group1"
        }
    ]
}

output [2]

{
    "serviceGroup": {
        "cartridges": *[*
*            "tomcat",*
*            "php"*
*        ],*
        "dependencies": {
            "startupOrders": "group.group1,cartridge.tomcat",
            "terminationBehaviour": "terminate-dependents"
        },
        "name": "group6",
        "subGroups": "group2"
    }
}

[1]
http://stackoverflow.com/questions/18918091/when-a-list-has-only-one-element-cxf-return-the-object-instead-a-js-array
-- 

Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware

web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897

Reply via email to