I have Play framework 2.0.4
installed. For the java app I have, I want to render response in JSON
format.
But when I was using renderJSON
, compiler gives:
The method
renderJSON(Map<String,String>)
is undefined for the type Status
what am I missing here?
public class Status extends Controller {
public static void myMethod(String url) {
Map<String, String> map = new HashMap<String, String>();
map.put("id", "1069");
map.put("url", url);
renderJSON(map);
}
}
I guess you are trying to port an application from version 1 to 2? In Play 2, this is how you return a JSON response:
ObjectNode result = Json.newObject();
result.put("id", "1069");
result.put("url", url);
return ok(result);
You should also have a look at the documentation .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.