asValue

inline fun <T> Flow<JsonNode>.asValue(objectMapper: ObjectMapper = defaultObjectMapper): Flow<T>

Converts a flow of JsonNode objects into a flow of objects of the specified type, using the provided ObjectMapper.

Return

A flow of objects of the specified type.

Example usage:

data class Person(val name: String, val age: Int)
val objectMapper = ObjectMapper()

val jsonNodeFlow = flowOf(
objectMapper.readTree("""{"name":"Alice","age":30}"""),
objectMapper.readTree("""{"name":"Bob","age":25}""")
)

jsonNodeFlow.asValue<Person>().collect { person -> println(person) }

Parameters

objectMapper

The ObjectMapper instance to use for converting JsonNode objects to objects. Defaults to defaultObjectMapper.