<https://gist.github.com/jeremyrempel/ff5821bd0991...
# serialization
r
Not sure if it's a bug or by design, but I've only ever gotten it working by using the
respond()
overload that takes a
ByteReadChannel
instead of a
String
.
j
respond(ByteReadChannel(testInput))
? That results in same error.
respond(String)
just maps to
respond(ByteReadChannel)
Is there any practical advantage to using the ktor jsonfeature vs just json.parse() api?
At least until feature Support I/O stream #204
r
Looks like I was mistaken. Issue isn’t the channel vs string, it just needs a json header so it knows what content to deserialize. Try this:
Copy code
respond(
    content = body,
    headers = headersOf(HttpHeaders.ContentType, "application/json")
)
🙏 1
As to your other question, I think the advantage of JsonFeature is it’s a serializer-agnostic API. So you could do something like substitute Gson or Moshi on the JVM side, if you wanted.
j
That worked; Thanks!