簡體   English   中英

在Play框架中將POJO轉換為JSON

[英]POJO to JSON in Play framework

嘗試獲取Play 2.0以從POJO返回JSON。 但我收到錯誤

The method toJson(Writes<A>) in the type Json is not applicable for the arguments (Product)

我的代碼是:

public static Result index(String date) {
     Product item = new Product();
    return ok(Json.toJson(item));

   }

有任何想法嗎?

確保使用import play.libs.Json導入正確的Json類。

您可能使用了針對Scala API(而非Java API)的play.api.libs.Json

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM