Hi Selva,
you might want to implement a ContextResolver and register your bean
there, to get the JSON as per the natural notation.
Please refer to this blog entry -
https://blogs.oracle.com/japod/entry/configuring_json_for_restful_web
HTH,
Naresh
On Mon, Oct 8, 2012 at 10:54 AM, selvakumar netaji
<vvekselva.gm_at_gmail.com>wrote:
> Hi All,
>
>
> I have exposed the services of my application as Jersey Rest and the
> responses would be in the json format.
>
> The Json format is accomplished by building a bean with the JAXB
> Annotations.
>
> The JAXB domain bean might have a collection (an array) or separate fields
> such as string, int or other wrappers.
>
> These wrappers are also annotated with the annotations.
>
> Everything is working fine except, if the collection contains only one
> element then the json - response is transmitted as
> a object and not as a collection, and if it contains more than one it is
> transmitted as collection.
>
> The services are annotated with @Produces(MediaType.APPLICATION_JSON).
>
> The same services are working fine if the return type is changed to
> string instead of a domain object,
> and responded with the string containing the serialized json value for the
> domain object by using
> any of the JSON Serializer. I'm using netsf json serializers.
>
>
> Warm Regards,
> Selvakumar N.
>
>
>