I'm about to choose a JSON library to a spring based application and want to g开发者_开发技巧et some pros and cons for both solutions. Of course conditional pros and cons are well seen :)
Thanks in advance!
If performance matters, there is nothing on Java platform that comes even close to Jackson with respect to performance (see this, this or this as initial data points). Some newer libraries (such as "json-smart") claim to be lightweight, fast(er), but have no external verification; most often since their own results do not follow performance measurement best practices. So to know performance details for your specific use case, do test them with your own data and see how things go, in addition to doing bit of googling.
Other than performance, there's this blog post ("7 Jackson killer features") that outlines what Jackson has to offer on its own (not considering integration with frameworks) -- other libraries have their own strengths, and for flex-json I understand its output side (writing JSON) is quite flexible and powerful. And if you absolutely want to minimize JSON library (jar) size, "Stringtree" and GSON-streaming are decent choices (but do not offer data-binding).
I can't say much about Spring-JSON, but I've found Jackson to be an extremely mature and flexible solution. It's well integrated with Spring itself; for example, if you have Jackson on the classpath, you get support for JSON with @ResponseBody-annotated methods. It's reasonably fast, and has good documentation.
For my project, Spring 3.0.5 works seamlessly with Jackson 1.6.3 (jackson-core-asl-1.6.3.jar, jackson-mapper-asl-1.6.3.jar)
精彩评论