Spring Batch JSON 支持
Spring Batch 4.1 开始能够支持 JSON 格式了。这个发布介绍了一个新的数据读(item reader)能够读取一个 JSON 资源,这个资源按照下面的格式:
与针对 XML 的
如果你还希望添加其他的库的话,你可以实现
JSON 数据的写是通过
有关更多 JSON 数据的支持,请参考 ItemReaders and ItemWriters 章节中的内容。
https://www.cwiki.us/display/SpringBatchZH/JSON+support
[
{
"isin": "123",
"quantity": 1,
"price": 1.2,
"customer": "foo"
},
{
"isin": "456",
"quantity": 2,
"price": 1.4,
"customer": "bar"
}
]
与针对 XML 的
StaxEventItemReader 类似,新的 JsonItemReader 使用流 API(streaming APIs)来读取 JSON 对象到块中。Spring Batch 能够支持下面 2 个库:如果你还希望添加其他的库的话,你可以实现
JsonObjectReader 接口。JSON 数据的写是通过
JsonFileItemWriter 来支持的。有关更多 JSON 数据的支持,请参考 ItemReaders and ItemWriters 章节中的内容。
https://www.cwiki.us/display/SpringBatchZH/JSON+support
Comments
Post a Comment