```fun <http://java.io|java.io>.InputStream.extrac...
# gradle
t
Copy code
fun <http://java.io|java.io>.InputStream.extractSummary(): String =
    ((JsonSlurper().parse(this) as Map<String, Any>)["fields"] as Map<String, Any>)["summary"] as String
I looked around a lot, couldn't find a way to make this code block simpler. Would like to do something similar to Groovy, which allows me to call just
this.fields.summary
. Any ideas?
r
That’s because Groovy isn’t really typed. Try to parse your InputStream as an actual model instead of just a map
t
JsonSlurper won't give me that option and I don't want to add a library to do that
m
You could add extension functions on
Map
and
InputStream
so that it becomes
this.parse().getObject("fields").getString("summary")
👍 1