Any success implementing a `JSON` response with KT...
# ktor
n
Any success implementing a
JSON
response with KTOR? Tried and got this:
Copy code
java.lang.IllegalArgumentException: Response pipeline couldn't transform 'class java.util.Collections$SingletonMap' to the OutgoingContent
	at io.ktor.server.engine.BaseApplicationResponse$$special$$inlined$apply$lambda$1.invokeSuspend(BaseApplicationResponse.kt:38)
	at io.ktor.server.engine.BaseApplicationResponse$$special$$inlined$apply$lambda$1.invoke(BaseApplicationResponse.kt)
	at io.ktor.util.pipeline.PipelineContext.proceed(PipelineContext.kt:53)
	at io.ktor.util.pipeline.Pipeline.execute(Pipeline.kt:24)
Checked out the documentation and saw this:
install(ContentNegotiation)
... but documentation is sketchy ... any ideas?
m
I made a toy project that shows how to do this (and other typical integrations): https://bitbucket.org/marshallpierce/ktor-demo/src/master/
s
You must declare with library will be used for ContentNegotiation
For example, gson
Copy code
implementation "io.ktor:ktor-gson:$ktor_version"
Copy code
install(ContentNegotiation) { gson {} }
n
@Sergio Casero Yes I tried all that, but the contents of the
gson { }
block, its somewhat unclear as to what needs to go there!
@mp will definitely take a look. Thanks 👍