Skip to content

ddivin-sc/spring-batch-json

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

spring-batch-json

Spring Batch custom extension to handle json. It use jackson streaming api to save memory use. It is useful when you need to handle big size of items or json file.

JacksonJsonStreamItemReader

You can read json object or array.

Example

Read array format json file

json file
[
  {
    "id": 1,
    "name": "cosmos",
    "author": "cal"
  },
  {
    "id": 2,
    "name": "The secret",
    "author": "cal"
  }
]
bean configuration
<bean class="com.bebeside77.spring.batch.json.JacksonJsonStreamItemReader">
  <property name="filePath" value="./some_json_file.json"/>
  <property bame="mappingClass" value="com.bebeside77.spring.batch.json.Book"/>
</bean>

Read object format json file

json file
{
  "type": "CREATE",
  "books": [
    {
      "id": 1,
      "name": "cosmos",
      "author": "cal"
    },
    {
      "id": 2,
      "name": "The secret",
      "author": "cal"
    }
  ]
}
bean configuration
<bean class="com.bebeside77.spring.batch.json.JacksonJsonStreamItemReader">
  <property name="filePath" value="./some_json_file.json"/>
  <property name="arrayName" value="books"/>
  <property bame="mappingClass" value="com.bebeside77.spring.batch.json.Book"/>
</bean>

JacksonJsonStreamItemWriter

You can write items to json file. It support only json array format.

Example

bean configuration
<bean class="com.bebeside77.spring.batch.json.JacksonJsonStreamItemWriter">
  <property name="outputFilePath" value="./output_file.json"/>
  <property name="encoding" value="utf8"/>
</bean>

Constraint

  • Minimum Java version : 1.8

About

spring batch extension to handle json.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%