Class JsonLineMapper
- java.lang.Object
- org.springframework.batch.item.file.mapping.JsonLineMapper
- All Implemented Interfaces:
LineMapper<java.util.Map<java.lang.String,java.lang.Object>>
public class JsonLineMapper extends java.lang.Object implements LineMapper<java.util.Map<java.lang.String,java.lang.Object>>
Interpret a line as a JSON object and parse it up to a Map. The line should be a standard JSON object, starting with "{" and ending with "}" and composed ofname:value
pairs separated by commas. Whitespace is ignored, e.g.{ "foo" : "bar", "value" : 123 }
The values can also be JSON objects (which are converted to maps):{ "foo": "bar", "map": { "one": 1, "two": 2}}
- Author:
- Dave Syer
Constructor Summary
Constructors Constructor Description JsonLineMapper()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
mapLine(java.lang.String line, int lineNumber)
Interpret the line as a Json object and create a Map from it.
Method Detail
mapLine
public java.util.Map<java.lang.String,java.lang.Object> mapLine(java.lang.String line, int lineNumber) throws java.lang.Exception
Interpret the line as a Json object and create a Map from it.- Specified by:
mapLine
in interfaceLineMapper<java.util.Map<java.lang.String,java.lang.Object>>
- Parameters:
line
- to be mappedlineNumber
- of the current line- Returns:
- mapped object of type T
- Throws:
java.lang.Exception
- if error occurred while parsing.- See Also:
LineMapper.mapLine(String, int)