asParsedJson

inline fun <T> Flow<String>.asParsedJson(objectMapper: ObjectMapper = defaultObjectMapper): Flow<T>

Converts a flow of JSON strings 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 jsonStringFlow = flowOf("""{"name":"Alice","age":30}""", """{"name":"Bob","age":25}""")

jsonStringFlow.asParsedJson<Person>().collect { person -> println(person) }

Parameters

objectMapper

The ObjectMapper instance to use for converting JSON strings to objects. Defaults to defaultObjectMapper.