Since release 3.0.0.M4 the springframework provides an own json-view - MappingJacksonJsonView. It is based on the Jackson Java JSON-processor http://jackson.codehaus.org/.
The last release of the project was spring-json-1.3.0. http://spring-json.sourceforge.net/. It provides some more universal and advanced filter capilities.
For testing I used the modification spring-json demoapp and swapped the view components.
Here my comparison result:
springframework MappingJackson JsonView | spring-json / sojo | spring-json / json-lib | spring-json / xstream | |
version | 3.0.0.M4 | 1.3.0 / 0.5.0
| 1.3.0 / 2.2.3 | 1.3.0 / 1.3 |
Streamingsupport | X | X | ||
JSON Hijackprotection | X | X | X | X |
CustomConverter | X | X | X | |
Global- and Feld-Errors | X | X | X | |
exceptions | X | X | X | |
exclude properties | X annotation / view property | X view property | X view property | X annotation / view property |
speed | ++ | 0 | 0 | + |
conformants | ++
| 0 no boolean isSetter, Enumeration, sm | ++ javascript functions | ++
|
annotation support | ++ | no | no | + |
licence | GPL / ALS | Apache2 | Apache 2 | Apache 2 |
Maven2 repro | SpringSource Enterprise Bundle Repository | Maven 2 - central repository / spring-json project repository | Maven 2 - central repository | Maven 2 - central repository |
Customizing Behaviour | 0 | 0 | + | ++ |
The strength of spring-json view the good integration to spring-mvc. It provides the same binding- and validation capabilities like we now from the JstlView. It supports the Custom(Value)ConverterRegistration and error- and exception-handling.
MappingJacksonJsonView is very fast and has a good annotation support.
Fazit:
spring-json view is well designed to swap a "classic" spring-mvc application to a Web 2.0
application just by changing the view while keeping the back-end
almost unchanged. If you start a new Web 2.0
application you can use your "old" spring-mvc knowledge to design complex json communication easily.
MappingJacksonJsonView is a very fast and quick to develope way for representing a model as a json-stream. no more and less. It strickly follows the new way of spring configuration by supporting spring-mvc and jackson anotations.
联系客服