Bug 209969 - JSON response format is not readable by JavaScript libraries like backbone.js
JSON response format is not readable by JavaScript libraries like backbone.js
Status: RESOLVED FIXED
Product: webservices
Classification: Unclassified
Component: REST
7.1.1
All All
: P3 (vote)
: 7.3
Assigned To: Denis Anisimov
issues@webservices
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-22 23:09 UTC by David Konecny
Modified: 2012-08-02 02:32 UTC (History)
2 users (show)

See Also:
Issue Type: TASK
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Konecny 2012-03-22 23:09:11 UTC
As discussed in issue 209515 the formatting of JSON response on GlassFish 3.1.1 is incompatible with what some clients expect. For example instead of expected

  [{"name":"abc","map":{"key3":"value4","1":"2"}}]

the GlassFish with Jersey version<2 responses with:

  {"data":{"name":"abc","map":{"entry":[{"key":"key3","value":"value4"},{"key":"1","value":"2"}]}}}

We should think how to make this working out of the box for users who are writing static web client applications based on JavaScript.

In vanilla JAX-RS case the solution can be:

A) add jackson-jaxrs-1.7.1.jar to project's classpath

or

B) return org.codehaus.jackson.jaxrs.JacksonJsonProvider provider in user's implementation of javax.ws.rs.core.Application.getClasses (eg. by calling Class.forName("org.codehaus.jackson.jaxrs.JacksonJsonProvider") which will succeed in runtime)

In Jersey case the solution is to add following parameter to Jersey's servlet:

  <init-param>
    <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
    <param-value>true</param-value>
  </init-param>
Comment 1 Petr Jiricka 2012-03-23 09:09:07 UTC
It would be useful to know what's the proposed solution for Jersey 2.0, so we can make this future-proof and consistent with the future behavior.
Comment 2 Denis Anisimov 2012-07-31 07:36:08 UTC
The problem is not glassfish-only.
The same issue is valid for WL.
It's common Jersey-related issue.
Comment 3 Denis Anisimov 2012-08-01 11:32:08 UTC
web-main#6fdde71e18ea
Comment 4 Quality Engineering 2012-08-02 02:32:53 UTC
Integrated into 'main-golden', will be available in build *201208020001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/6fdde71e18ea
User: Denis Anisimov <ads@netbeans.org>
Log: Fix for BZ#209969 - JSON response format is not readable by JavaScript libraries like backbone.js


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo