cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thorsten Scherler <thors...@apache.org>
Subject c3 and JSON
Date Tue, 12 Apr 2011 11:42:04 GMT
Hi all,

as I mentioned in another mail I am ATM developing a prototype based on
c3. In another recent project we worked with jersey [1], which is the
reference implementation for JAX-RS (JSR 311).

Our c3 prototype will expose a couple of REST services and looking at
the c3 sources I have not found any references to return a JSONObject
like follows in our REST services. 

JSONObject object = JSONObject.fromObject(answerBean);
return object.toString();

where in c3 I do:

return new URLResponse("servlet:/controller/screen", data);

I looked at the URLResponse and on some other classes that implement
RestResponse. In my understanding I need to create a JsonResponse which
would do something like:

JSONObject object = JSONObject.fromObject(answerBean);
return new JsonResponse(object);

and in the JsonResponse
public class JsonResponse implements RestResponse{
execute(...){
  IOUtils.write(data.toString(), outputStream);
...
}

Well I did it and it worked very nicely. :)

I needed to add 
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
to my POM, though. 

Is this from general interest and should I commit the JsonResponse into
the package org.apache.cocoon.rest.controller.response?

salu2

[1] http://jersey.java.net/
-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/

Mime
View raw message