playframework - implicit json read and writes for lists -


i following following example https://github.com/leon/play-salat/tree/master/sample . in data model have lists , tried adopt model that.

i following compilation errors:

[error] /home/malte/workspace/bdt/app/models/ballot.scala:26: no json deserializer found        type list[models.position]. try implement implicit writes or format type. [error]         "positions" -> b.positions, [error]                          ^ [error] /home/malte/workspace/bdt/app/models/ballot.scala:33: no json deserializer found type list[models.position]. try implement implicit reads or format type. [error]       (__ \ 'values).read[list[position]]).map { l => l.getorelse(nil) } ~ 

for type "position" have implicit reads , writes, how make list[position] ? implicit write , read:

implicit val ballotjsonwrite = new writes[ballot] {   def writes(b: ballot): jsvalue = {     json.obj(       "positions" -> b.positions,       "title" -> b.title)   } }  implicit val ballotjsonread = ( (__ \ 'positions).readnullable(   (__ \ 'values).read[list[position]]).map { l => l.getorelse(nil) } ~   (__ \ 'title).read[string])(ballot.apply _) 

for read followed create implicit json read list collection might missing input json , above mentioned error.

actually found out in latest versions of salat. json automatically used move between models , json objects. removed whole part , no runs smoothly.

https://github.com/novus/salat/wiki/json


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -