Play Framework 2 JSON Reads, deserialization of one variable -
i'm using play framework 2.4 , i'm trying basic json deserialization reads error. here code:
case class config(action: string) and somewhere,
implicit val configreads: reads[config] = ( (__ \ "action").read[string] )(config.apply _) i think configreads correctly formed ide error on "read" method call (symbol not defined), when compile code following error:
error:(30, 27) overloaded method value read alternatives: (t: string)play.api.libs.json.reads[string] <and> (implicit r: play.api.libs.json.reads[string])play.api.libs.json.reads[string] cannot applied (string => wings.common.json.config) (__ \ "action").read[string] ^ but, if instead of trying deserialize 1 argument declare class 2 arguments in constructor , write code deserialize it, works.
does know how solve this?
edit:
digging in depth of google found this play 2.1.x i'm using json library play 2.4.1 problem should not happening.
you can this:
implicit val configreads: reads[config] = ( (__ \ "action").read[string] ) map config.apply
Comments
Post a Comment