play-authenticate icon indicating copy to clipboard operation
play-authenticate copied to clipboard

Is it possible to return JSON response?

Open tanmaydesai89 opened this issue 11 years ago • 4 comments

Greetings.

I wanted to know if it is possible to send response as JSON. I don't want to render scala for front-end. For example, when I send form data with post request on mydomain.com/signup, is it possible that JSON data can be returned?

tanmaydesai89 avatar Jul 21 '14 11:07 tanmaydesai89

did you have a look at the sample and check if you can modify the templates according to your needs?

joscha avatar Jul 21 '14 11:07 joscha

Hi @joscha : I am not much of a java guy, but PlayAuthenticate returns Result. Can you point me to the right direction. Struggling to find way since yesterday. I need to use this module for Android app.

tanmaydesai89 avatar Jul 21 '14 11:07 tanmaydesai89

Result is generated from a twirl template. Twirl templates can have any format. If you change Globals.java to use your own routes with Twirl templates that return JSON it should work.

joscha avatar Jul 21 '14 12:07 joscha

 public static Result index() {
           return ok( Json.toJson ("output your Json"));
    }

keepscoding avatar May 22 '15 13:05 keepscoding