Jackson:项目结构分析

Jackson库是Java和JVM平台上的数据处理工具集,包括流式JSON解析器、数据绑定库和多种数据格式支持模块。核心模块如Streaming、Annotations、Databind支持基本的JSON处理,而Datatype模块则为Eclipse Collections、Guava、Hibernate等第三方库提供数据类型支持。JAX-RS Providers为RESTful Web服务提供JSON、XML等格式的支持,Dataformat模块则覆盖了Avro、BSON、XML等多种数据交换格式。

目录

1、核心modules

2、datatype modules

3、JAX-RS(Java API for RESTful Web Services)支持

4、Data format modules

5、JVM系语言支持


作为java体系下标准的json函数库,目前默认被应用在spring boot中。jackson是一套用于Java和JVM平台的数据处理工具,包括流式json解析器/生成器函数库、数据绑定函数库(POJO和JSON的互转),以及用以处理Avro,BSON,CBOR,CSV,Smile,(Java)Properties,Protobuf,XML,和YAML编码的数据格式化模块。还有很多的数据格式模块用以支持更广泛的数据类型,诸如Guava,Joda,PCollections中的更多其他的数据类型也是支持转换的。

1、核心modules

实际的核心组件属于他们自己的项目下-包括三个核心程序包(streaming【core】,databind,annotations),数据格式(dataformat)函数库,数据类型(datatype)库,JAX-RS(提供JSON、Smile【binary JSON】、CBOR【another kind of binary JSON】、XML、YAML的自动注册)

核心modules

  1. Streaming(jackson-core):定义了较低级别的流式API,并包含JSON的特定实现
  2. Annotations(jackson-annotations):包含jackson的标准注解
  3. Databind(jackson-databind):在Streaming包上实现了数据绑定和对象序列化,它依赖于以上两个包

2、datatype modules

支持第三方数据类型的modules

这些扩展作为jackson的module的插件(以ObjectMapper.registerModule()的方式),并通过添加序列化器和反序列化器来支持常用java库的数据类型,以便databind包(objectMapper,objectReader,objectWriter)能够对这些类型进行读写。

以下这些数据类型包是由jackson团队进行维护的:

此外,jackson团队并未直接维护的modules:

3、JAX-RS(Java API for RESTful Web Services)支持

Jackson JAX-RS Providers has handlers to add dataformat support for JAX-RS implementations (like Jersey, RESTeasy, CXF). Providers implement MessageBodyReader and MessageBodyWriter. Supported formats currently include JSONSmileXMLYAML and CBOR.

4、Data format modules

Data format modules 提供了除json外的其他格式支持。大部分都是简单继承了streaming的api,所以databinding组件可以使用。

  • Avro: supports Avro data format, with streaming implementation plus additional databind-level support for Avro Schemas
  • CBOR: supports CBOR data format (a binary JSON variant).
  • CSV: supports Comma-separated values format -- streaming api, with optional convenience databind additions
  • Ion (NEW with Jackson 2.9!): support for Amazon Ion binary data format (similar to CBOR, Smile, i.e. binary JSON - like)
  • (Java) Properties (2.8): creating nested structure out of implied notation (dotted by default, configurable), flattening similarly on serialization
  • Protobuf (2.6): supported similar to Avro
  • Smile: supports Smile (binary JSON) -- 100% API/logical model compatible via streaming API, no changes for databind
  • XML: supports XML; provides both streaming and databind implementations. Similar to JAXB' "code-first" mode (no support for "XML Schema first", but can use JAXB beans)
  • YAML: supports YAML, which being similar to JSON is fully supported with simple streaming implementation

另外,还有一些由其他人员开发的data format 的modules:

  • BEncode: support for reading/writing BEncode (BitTorrent format) encoded data
  • bson4jackson: adds support for BSON data format (by Mongo project).
    • Implemented as full streaming implementation, which allows full access (streaming, data-binding, tree-model)
    • Also see [MongoJack] library below; while not a dataformat module, it allows access to BSON data as well.
  • EXIficient supports Efficient XML Interchange
  • jackson-dataformat-msgpack adds support MessagePack (aka MsgPack) format
    • Implemented as full streaming implementation, which allows full access (streaming, data-binding, tree-model)
  • HOCON: experimental, partial implementation to support HOCON format -- work in progress
  • Rison: Jackson backend to support Rison)

5、JVM系语言支持

  • Kotlin to handle native types of Kotlin
  • Scala to handle native Scala types (including but not limited to Scala collection/map types, case classes)
    • Currently (April 2020) Scala 2.10, 2.11, 2.12 and 2.13 are supported (2.9 was supported up to Jackson 2.3)
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值