If I had a data class that looks like `data class ...
# announcements
k
If I had a data class that looks like
data class Sample(val foo: Number)
and the following example map that I may not know until runtime
mapOf("foo" to 1, "bar" to 2, "baz" to 3)
. How can I extract just the value that's relevant to the
Sample
data class and build it when I don't know if the field in question will be present?
d
if jackson's objectmapper is an option it's as simple as
Copy code
ObjectMapper().convertValue<Sample>(map)
c
d
k
Thanks! That's really useful