Reputation:
In a Scala controller, I can simply render a response (for dev pursposes) using the magical """
:
Ok("""{"key":"value"}"""}
In a Java controller, this obviously doesn't work. Is there a quick way to render a JSON string as a response? (that is too long to escape manually without hitting my head against a wall)
I don't want to do:
ok("{\"key\":\"value\"}");
Upvotes: 2
Views: 227
Reputation: 29693
No. """
it's feature from Scala
and Groovy
programming languages. In Java no analogue.
You can try
ok("{'key':'value'}");
but it does not always work
Upvotes: 1
Reputation: 42047
The only way I see is to write a small shell script or scala script to do the escaping for you and then copy/paste the output of that into your java file.
Upvotes: 0