Kin*_*gFu 5 java json playframework-2.0
试图让Play 2.0从POJO返回JSON.但我收到了错误
The method toJson(Writes<A>) in the type Json is not applicable for the arguments (Product)
Run Code Online (Sandbox Code Playgroud)
我的代码是:
public static Result index(String date) {
Product item = new Product();
return ok(Json.toJson(item));
}
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
nde*_*rge 19
确保使用导入正确的Json
类import play.libs.Json
.
您可能使用的play.api.libs.Json
是Scala API的目标,而不是Java API.