I know a small reproducible case would be best, but I can't get that to reproduce the problem right now. I am just using the JSONJAXBContext with the natural JSONConfiguration.
On Dec 14, 2010, at 8:13 AM, Jakub Podlesak wrote:
> Hi Jason,
>
> Do you use a special JSON configuration setting in your application?
> Could you share some details on it?
>
> The most helpful would be to provide a simple reproducible test case.
> Ideally a maven project.
>
> Thanks,
>
> ~Jakub
>
> On 12/06/2010 10:38 PM, Jason Erickson wrote:
>>
>> I have a method (a few actually, but this will do for an example):
>>
>> @GET
>> @Produces(MediaType.APPLICATION_JSON)
>> public Observation[] getObservations(
>> @QueryParam("startDate") Date startDate,
>> @QueryParam("endDate") Date endDate,
>> @QueryParam("observerId") Long observerId,
>> @QueryParam("observerName") String observerName,
>> @QueryParam("subjectId") Long subjectId,
>> @QueryParam("subjectName") String subjectName,
>> @QueryParam("phenomenonId") Long phenomenonId,
>> @QueryParam("page") @DefaultValue("0") int page,
>> @QueryParam("pageSize") @DefaultValue("25") int pageSize) {
>> ObservationCriteria criteria = new ObservationCriteria();
>> criteria.setStartDate(startDate);
>> criteria.setEndDate(endDate);
>> criteria.setPage(page);
>> criteria.setPageSize(pageSize);
>> criteria.setObserverId(observerId);
>> criteria.setObserverName(observerName);
>> criteria.setSubjectId(subjectId);
>> criteria.setSubjectName(subjectName);
>> criteria.setPhenomenonId(phenomenonId);
>> List<Observation> obsResult = observationDao.getByCriteria(criteria);
>> return obsResult.toArray(new Observation[] {});
>> }
>>
>>
>> The data I get back is correct. However, when I deploy the application in jetty, the response is returned as a JSON object with one named field that contains the array like:
>> {"observation": [{"id":"440", "date":"2010-10-28"},{"id":"308", "date":"2010-10-28"}]}
>>
>> When I deploy the same application to tomcat 6, the response is returned as a JSON array like:
>> [{"id":"440", "date":"2010-10-28"},{"id":"308", "date":"2010-10-28"}]
>>
>> Is this a bug? Is there a workaround?
>