How am I supposed to create a `Response` with JSON...
# http4k
m
How am I supposed to create a
Response
with JSON from a string? This seems to work:
Copy code
Response(Status.OK).header("Content-Type", ContentType.APPLICATION_JSON.value).body("""{"foo":"bar","baz":17}""")
but is there some nicer way?
d
you want a lens.
m
In this case I have "free format" JSON in a string, with no corresponding schema or class.
d
then you can just use a Map<String, Any>
it will work just the same
if it's just a string then you can probably use
Body.string(ContentType.APPLICATION_JSON).toLens()
m
Ah, that works. Nice.