-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSON formatting view for Spring MVC [SPR-5853] #10522
Comments
Andres Almiray commented Maven project with JsonView + tests. Includes the following dependencies: |
Rob Harrop commented Very interesting. I did the exact same thing recently as part of a prototype. I hope to get something like this in Spring 2.1 along with a JsonServiceExporter. Rob |
Andres Almiray commented Rob, json-lib transforms beans, maps, collections and arrays to JSON format, but the current development snapshot can transform JSON to DynaBeans, collections, arrays and beans (althought the primitive array conversion still needs some work). Andres |
Rogier Goede commented json-lib implementation of a ServiceExporter with dojo support |
Rogier Goede commented I was exactly on that track when I wrote the inappropriately named SmdServiceExporter. var testClass = new dojo.rpc.JsonService("/dojo_test_server/remoting/TestService"); This is enough to call a method on a server side bean and pass the result to the mapContentCallBack function.
|
Andres Almiray commented I think that we have three different issues mixed, let me explain,
|
Julian Dreißig commented In renderMergedOutputModel, you have to actually set the contentType of the response, like response.setContentType(this.getContentType()); |
Condor commented I would like to propose some changes to JsonView:
|
Andres Almiray commented Updated code to maven2, json-lib-1.0b2, ezmorph-1.0, jstester-1.3. |
Condor commented Wow, that was quick update ! Some notes on JsonView v2:
|
Andres Almiray commented Update with latest suggestions from M.H. Avegaart |
Domenico Testa commented I've noticed the use of an old version of the json-lib (the stable version at the time of writing is 2.1). Watch at the attached file JsonView.java. |
Domenico Testa commented View updated to support json-lib 2.1 |
Condor commented I suggest adding an extra method between renderMergedOutputModel and createJSON that allowes for overriding when JSON output is written directly to the response (e.g. when using net.sf.json.util.JSONBuilder). Change: protected void writeJSON(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { protected void renderMergedOutputModel(Map model, HttpServletRequest request, HttpServletResponse response) throws Exception { |
Andres Almiray commented I decided to release JsonView as an extension of Json-lib. If anyone is interested the package is available at M.H. Avegaart: I included your latest suggestion too. |
Chad Shryock commented How does one use this? Is there documentation anywhere? |
Lari Hotari commented Please checkout the features in http://spring-json.sourceforge.net/ . Besides json view, it also supports AJAX form validation and submission using spring mvc. It would be nice to get these features in standard Spring MVC. Spring-Json works well with ExtJS (with a little tweaking). |
Andres Almiray commented Speaking for the JsonView code attached to this issue (latest version [1.0.1] available at http://sourceforge.net/projects/json-lib) you may configure it as you would with any other SpringMVC view. It also accepts a JsonConfig bean to further customize how beans must be serialized. |
Paul Sundling commented I see there is also a project that seems to solve this called spring-json http://spring-json.sourceforge.net/ which supports both sojo and json-lib. Which implementation, or yet a third solution will be included in Spring 3? |
Kirill Kovalchuk commented Rogier, what is the status for SmdServiceExporter? I'm searching scalable, supportable solution for my projects to build a bridge between Browser and Spring's Services - I just want to be able to call remote method using Javacript and searching for an appropriate ServiceExporter. In this issue we can see two solutions:
Advantages of SmdServiceExporter:
Disadvantages of SmdServiceExporter:
Advantages of JSONRPCServiceExporter:
Disadvantages of JSONRPCServiceExporter:
Conclusion: I think SmdServiceExporter is better than JSONRPCServiceExporter for a long perspective because:
But I found some difficulties compiling SmdServiceExporter with latest versions of dojo and json-lib and I think that it doesn't support complex types. So if Rogier would share us updated version it would be appreciated. BR |
Brian C. Dilley commented I've created a project for a springframework JSON-RPC based RemoteExporter at the following URL: http://code.google.com/p/spring-jsonrpc/ It's based on the specification being written at: http://groups.google.com/group/json-rpc note: The code for this project is not the same code attached to this issue - it's completely different. I just figured I'd let everyone know that it exists :) |
Andres Almiray opened SPR-5853 and commented
Create a view that outputs its model as a JSON object. This will help AJAX enabled applications to transfer less bytes as the JSON format is more compact that XML. It also allows for quick object creation using eval(), no need for extra XML parsing.
I have created such view (JsonView) using the json-simple library (http://json.org/java) and would like to contribute it.
Attachments:
Issue Links:
Referenced from: commits 5ae919a, 398729c
26 votes, 26 watchers
The text was updated successfully, but these errors were encountered: