且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

发送和解析JSON对象

更新时间:2023-01-17 17:01:33

我很惊讶这些都没有被提及:但不是使用裸机,而手工工艺与json.org的小包装,GSON和杰克逊都方便多了使用。所以:

I am surprised these have not been mentioned: but instead of using bare-bones rather manual process with json.org's little package, GSon and Jackson are much more convenient to use. So:

  • GSON
  • Jackson

所以,你实际上可以绑定到自己的POJO,而不是一些半称职的树节点或列表和地图。 (至少杰克逊允许绑定到这些事情太(也许GSON为好,不知道),JsonNode,地图,列表,如果你真的想这些,而不是真实的对象)

So you can actually bind to your own POJOs, not some half-assed tree nodes or Lists and Maps. (and at least Jackson allows binding to such things too (perhaps GSON as well, not sure), JsonNode, Map, List, if you really want these instead of 'real' objects)

EDIT 19-MAR-2014:

EDIT 19-MAR-2014:

另一个新的竞争者是杰克逊JR 库:它使用相同的快速流解析器/发生器作为杰克逊(杰克逊核心),但数据绑定的部分很小(50KB)。功能较为有限(没有注释,只是普通的Java Bean)的,但是性能方面应该是快速和初始化(首次呼叫)的开销非常低。 因此,它也许会是不错的选择,尤其是对于较小的应用程序。

Another new contender is Jackson jr library: it uses same fast Streaming parser/generator as Jackson (jackson-core), but data-binding part is tiny (50kB). Functionality is more limited (no annotations, just regular Java Beans), but performance-wise should be fast, and initialization (first-call) overhead very low as well. So it just might be good choice, especially for smaller apps.