Hi :slightly_smiling_face: ```import com.fasterxml...
# getting-started
l
Hi 🙂
Copy code
import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.readValue

data class InsideList(
    @JsonProperty("price") val price: String,
    @JsonProperty("product") val product: String
)

data class NList(
    @JsonProperty("listexample") val listexample: List<InsideList>?
)
the
response
is the json list
Copy code
val jsonResponse = MapperUtility.jsonMapper.readValue<NList>(response)

println("Response : {${jsonResponse.listexample}}")
the print is:
NList(listexample=[InsideList(product=apple, price=ten)])
how can i print just the value of the product? i tried to do it with
forEach
but not works as expected 🙄
r
what you're looking for is the
map
function (or it's various alternatives) - it allows you to transform a list to a new one, by applying a function to each element:
Copy code
val prices: List<String>? = jsonResponse.listexample?.map { it.price }
l
Nicee now i know there is something like that 10x 👍