Class JsonRecordSeparatorPolicy
- java.lang.Object
- org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy
- org.springframework.batch.item.file.separator.JsonRecordSeparatorPolicy
- All Implemented Interfaces:
RecordSeparatorPolicy
public class JsonRecordSeparatorPolicy extends SimpleRecordSeparatorPolicy
JSON-based record separator. Waits for a valid JSON object before returning a complete line. A valid object has balanced braces ({}), possibly nested, and ends with a closing brace. This separator can be used to split a stream into JSON objects, even if those objects are spread over multiple lines, e.g.{"foo": "bar", "value": { "spam": 2 }} {"foo": "rab", "value": { "spam": 3, "foo": "bar" }}
- Author:
- Dave Syer
Constructor Summary
Constructors Constructor Description JsonRecordSeparatorPolicy()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isEndOfRecord(java.lang.String line)
True if the line can be parsed to a JSON object.Methods inherited from class org.springframework.batch.item.file.separator.SimpleRecordSeparatorPolicy
postProcess, preProcess
Method Detail
isEndOfRecord
public boolean isEndOfRecord(java.lang.String line)
True if the line can be parsed to a JSON object.- Specified by:
isEndOfRecord
in interfaceRecordSeparatorPolicy
- Overrides:
isEndOfRecord
in classSimpleRecordSeparatorPolicy
- Parameters:
line
- a String without a newline character at the end.- Returns:
- true if this line is a complete record.
- See Also:
RecordSeparatorPolicy.isEndOfRecord(String)