phldavies
01/22/2025, 10:36 PMwrap
method? I'd like to implement a json interpolator that implicitly uses Json.encodeToJsonElement()
when handling any parameter that isn't a json primitive. I can work around it by doing """{"field": ${json.encodeToJsonElement(myVal)}}"""
but would ideally use """{"field": $myVal}"""
(obviously using a helper can at least make this something like """{"field": ${json(myVal)}}"""
at least helps here)
I've tried inline fun <reified T> JsonInterpolator.wrap(value: T): JsonElement = Json.encodeToString(value)
but it doesn't like the type parameter and I'm guessing it won't properly inline the call either.