Home / Class/ DockerJson Class — spring-boot Architecture

DockerJson Class — spring-boot Architecture

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

Entity Profile

Source Code

core/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/DockerJson.java lines 34–77

final class DockerJson {

	private static final JsonMapper jsonMapper = JsonMapper.builder()
		.defaultLocale(Locale.ENGLISH)
		.enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
		.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
		.disable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
		.build();

	private DockerJson() {
	}

	/**
	 * Deserialize JSON to a list. Handles JSON arrays and multiple JSON objects in
	 * separate lines.
	 * @param <T> the item type
	 * @param json the source JSON
	 * @param itemType the item type
	 * @return a list of items
	 */
	static <T> List<T> deserializeToList(String json, Class<T> itemType) {
		if (json.startsWith("[")) {
			JavaType javaType = jsonMapper.getTypeFactory().constructCollectionType(List.class, itemType);
			return deserialize(json, javaType);
		}
		return json.trim().lines().map((line) -> deserialize(line, itemType)).toList();
	}

	/**
	 * Deserialize JSON to an object instance.
	 * @param <T> the result type
	 * @param json the source JSON
	 * @param type the result type
	 * @return the deserialized result
	 */
	static <T> T deserialize(String json, Class<T> type) {
		return deserialize(json, jsonMapper.getTypeFactory().constructType(type));
	}

	private static <T> T deserialize(String json, JavaType type) {
		return jsonMapper.readValue(json.trim(), type);
	}

}

Analyze Your Own Codebase

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

Try Supermodel Free