Package org.springframework.batch.item.file.separator

# 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

  Modifier and Type
  Method
  Description
  `boolean`
  `isEndOfRecord(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`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### JsonRecordSeparatorPolicy

    public JsonRecordSeparatorPolicy()

- ## Method Details

  - ### isEndOfRecord

    public boolean isEndOfRecord(String line)
    True if the line can be parsed to a JSON object.
    Specified by:
      `isEndOfRecord` in interface `RecordSeparatorPolicy`
    Overrides:
      `isEndOfRecord` in class `SimpleRecordSeparatorPolicy`
    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)`