The most significant problem for me was that by default, the system does not
accept what it produces. I used JAXB in a JAX-RS service which produces JSON
to return a Teacher object. It returns it as serialized array with the
square brackets:

<code>
        @GET
        @Path("/teacher")
        @Produces({
                MediaType.APPLICATION_JSON})
        @Consumes({
                MediaType.APPLICATION_JSON})
        public TeacherInfo getTeacherProfile(@QueryParam("id") String argId)
                        throws DashboardServiceException
        {
                TeacherInfo t = new TeacherInfo();
                // ...
                return t;
        }
</code>

Returns:

{"teacherInfo":[{"district_user_id":"foo","email":"[email protected]","enabled":true,"first_name":"Luly","last_name":"Larst","student_count":17,"title":"Mister"}]}

But then when I then the client returns the identical syntax, Tomee/JAXB
does not understand it. I get a TeacherInfo instance with all fields null
until I remove the square brackets.

<code>
        @POST
        @Path("/teacher/update")
        @Consumes({MediaType.APPLICATION_JSON})
        @RolesAllowed("teacher")
        public String updateTeacherProfile(TeacherInfo argTeacherInfo,
                        @CookieParam("sid") @QueryParam("sid") String argSid,
                        @Context MessageContext argMessageContext) throws
DashboardServiceException
        {
                *// all fields in argTeacherInfo are null!*
                // if I remove square brackets (no array), all fields bind 
properly
                
        }
</code> 

So I am writing a custom provider and/or interceptor to handle. It would be
preferable that whichever way we decide, the output should be matched to the
input. The JSON marshalled from JAXB should be easily unmarshalled from JAXB
without special handling. Seems to make much more sense that way. 
Ron



--
View this message in context: 
http://openejb.979440.n4.nabble.com/Possible-JSON-bug-in-TomEE-1-5-and-1-5-1-tp4658328p4658354.html
Sent from the OpenEJB User mailing list archive at Nabble.com.

Reply via email to