Home / Class/ JacksonJsonParser Class — spring-boot Architecture

JacksonJsonParser Class — spring-boot Architecture

Architecture documentation for the JacksonJsonParser class in JacksonJsonParser.java from the spring-boot codebase.

Entity Profile

Source Code

core/spring-boot/src/main/java/org/springframework/boot/json/JacksonJsonParser.java lines 33–80

public class JacksonJsonParser extends AbstractJsonParser {

	private static final MapTypeReference MAP_TYPE = new MapTypeReference();

	private static final ListTypeReference LIST_TYPE = new ListTypeReference();

	private @Nullable JsonMapper jsonMapper; // Late binding

	/**
	 * Creates an instance with the specified {@link JsonMapper}.
	 * @param jsonMapper the JSON mapper to use
	 */
	public JacksonJsonParser(JsonMapper jsonMapper) {
		this.jsonMapper = jsonMapper;
	}

	/**
	 * Creates an instance with a default {@link JsonMapper} that is created lazily.
	 */
	public JacksonJsonParser() {
	}

	@Override
	public Map<String, Object> parseMap(@Nullable String json) {
		return tryParse(() -> getJsonMapper().readValue(json, MAP_TYPE), Exception.class);
	}

	@Override
	public List<Object> parseList(@Nullable String json) {
		return tryParse(() -> getJsonMapper().readValue(json, LIST_TYPE), Exception.class);
	}

	private JsonMapper getJsonMapper() {
		if (this.jsonMapper == null) {
			this.jsonMapper = new JsonMapper();
		}
		return this.jsonMapper;
	}

	private static final class MapTypeReference extends TypeReference<Map<String, Object>> {

	}

	private static final class ListTypeReference extends TypeReference<List<Object>> {

	}

}

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free