2

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\"}");

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.