Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.springframework.batch.item.file.mapping;
 import java.util.Map;
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 of name: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}}

Dave Syer
public class JsonLineMapper implements LineMapper<Map<StringObject>> {
Interpret the line as a Json object and create a Map from it.

	public Map<StringObjectmapLine(String lineint lineNumberthrows Exception {
		try {
			Map<StringObjecttoken = parser.readValueAs(Map.class);
			result = token;
		catch (Exception e) {
			throw new FlatFileParseException("Cannot parse line to JSON"elinelineNumber);
		return result;
New to GrepCode? Check out our FAQ X