クライアントからJSONデータを読み込み、解析するため、挿入メソッドを使用してテーブルに挿入できますが、Play 2.5とSlick 3.1.1の暗黙的な読み取りOption [BigDecimal]にエラーがスローされます、なぜですか?PUT関数のコントローラークラスの暗黙的な読み取りSCALAプレイフレームワーク
object RBooks {implicit val xReads: Reads[xRow] = (
(JsPath \ "bookId").read[Option[BigDecimal]] and
(JsPath \ "bookName").read[Option[String]] and
(JsPath \ "bookDesc").read[Option[String]] and
(JsPath \ "enabled").read[Option[Char]] and
(JsPath \ "primaryBook").read[Option[Char]] and
(JsPath \ "bookType").read[Option[String]] and
(JsPath \ "bookCurrency").read[Option[String]] and
(JsPath \ "startDate").read[Option[java.sql.Timestamp]] and
(JsPath \ "endDate").read[Option[java.sql.Timestamp]] and
(JsPath \ "allocationsEnabled").read[Option[Char]] and
(JsPath \ "arrPrefix").read[Option[String]] and
(JsPath \ "creationDate").read[Option[java.sql.Timestamp]] and
(JsPath \ "createdBy").read[Option[String]] and
(JsPath \ "lastUpdateDate").read[Option[Timestamp]] and
(JsPath \ "lastUpdatedBy").read[Option[String]]
)(slickLib.xRow.apply _)
エラー出力Iが得る:
No Json deserializer found for type Option[BigDecimal]. Try to implement an implicit Reads or Format for this type.(xRow.apply _) this code is throwing a error: (JsPath \ "bookId").read[Option[BigDecimal]] and
プレイScalaでは.read
は、オプション[BigDecimalを]をサポートしていませんか?
は、なぜあなたは 'オプション[BigDecimalの]' 'の代わりにオプションの[10進】'のしたいですか? – jwvh
はい、私はOption [BigDecimal]を使用する必要があります。slickLib.xRow.apply _)は赤なしで取得します。コードを実行するとエラーが発生しますが、scalaがこの暗黙の読み取りを受け付けない理由はわかりません。 – governingcloud