convertToType

fun convertToType(value: Any, targetType: Type, objectMapper: <Error class: unknown class>, logger: <Error class: unknown class>): Any

Coerces value (typically from a JSON parse) to targetType.

Jackson deserialises JSON numbers as Int or Double; LLMs may also send numbers as quoted strings (e.g. "5" instead of 5). Both cases are handled. For complex types the ObjectMapper is used as a fallback.