###前提・実現したいこと
PlayFramework + Scalaで開発を行っています。
自作したクラスをJSONとしてファイルに読み書きしたいと考えています。
###発生している問題・エラーメッセージ
以下の記事を参考にJSONを作成しようと考えていましたが、以下のエラーが表示されコンパイルできません。
https://qiita.com/tagia0212/items/fdfe3c6141323ae281c3
No implicit format for List[StringLong], IntDouble available.
###該当のソースコード
StringLongのListとIntDoubleを要素に持つMyClassをJSON形式でファイル読み書きしたいと考えています。
scala
1case class MyClass(sl: List[StringLong], id: IntDouble) 2object MyClass{ 3 implicit def jsonWrites = Json.writes[MyClass] // ここでエラーメッセージ 4 implicit def jsonReads = Json.reads[MyClass] // ここでエラーメッセージ 5} 6case class StringLong(key: String, value: Long) 7object StringLong{ 8 implicit def jsonWrites = Json.writes[StringLong] 9 implicit def jsonReads = Json.reads[StringLong] 10} 11case class IntDouble(key: Int, value: Double) 12object IntDouble { 13 implicit def jsonWrites = Json.writes[IntDouble] 14 implicit def jsonReads = Json.reads[IntDouble] 15}
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/11/30 01:13