Hi,
As a solution to the issue descussed in thread "Json response shows arrays
as string when there are single value", I tried changing json provider
to org.codehaus.jackson.jaxrs.JacksonJaxbJsonProvider which was
earlier jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider
I tested cartridge, partition,policies, groups POST and GET operations with
the new provider and was successful.
*Advantages over existing provider*
1) support List without any configurations
Earlier when we have List in beans, we have to explicitly mention them in
cfx-servlet.xml as "serializeAsArray". With new provider, it is not needed.
<property name="serializeAsArray" value="true"/>
<property name="arrayKeys">
<list>
<value>partitions</value>
<value>property</value>
<value>hostNames</value>
<value>memberMap</value>
<value>portMap</value>
<value>partitionGroup</value>
<value>member</value>
<value>hostNames</value>
<value>portMappings</value>
<value>volumes</value>
<value>domains</value>
<value>kubernetesHost</value>
<value>cartridges</value>
</list>
</property>
2) Root element is automatically removed
*Disadvantages*
1) Similar to adding [] brackets when it is a list in GET requests, we
have to put [] to list when we are doing POST even when there is one
element
for instance have a look at the partition.json
{
"id": "temp",
"provider": "ec2",
"property":* [*
{
"name": "region",
"value": "ap-southeast-1"
}
*]*,
"partitionMin": "1",
"partitionMax": "3"
}
2) Show null values too (There might be configurations to avoid this)
{
"cartridges": [
"mysql"
],
"dependencies": {
"startupOrders": [
* null*
],
"terminationBehaviour": "terminate-none"
},
"name": "group111",
"subGroups": [
* null*
]
}
Do we move to the new provider at this time or wait till m4 is released?
--
Udara Liyanage
Software Engineer
WSO2, Inc.: http://wso2.com
lean. enterprise. middleware
web: http://udaraliyanage.wordpress.com
phone: +94 71 443 6897