Skip to content

Instantly share code, notes, and snippets.

@gbougeard
Created November 18, 2013 15:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbougeard/7529214 to your computer and use it in GitHub Desktop.
Save gbougeard/7529214 to your computer and use it in GitHub Desktop.
implicit val reads: Reads[PostedMessage] = (
(__ \ "_id").read[String] ~
(__ \ "@message").read[String] ~
(__ \ "_source" \ "@fields" \ "CPAID").read[String] ~
(__ \ "_source" \ "@fields" \ "frompartyid").read[String] ~
(__ \ "_source" \ "@fields" \ "topartyid").read[String] ~
(__ \ "_source" \ "@fields" \ "CONVERSATIONID").read[String] ~
(__ \ "_source" \ "@fields" \ "msgId").read[String] ~
(__ \ "_source" \ "@fields" \ "action").read[String] ~
(__ \ "_source" \ "@fields" \ "service").read[String]
)(PostedMessage.apply _)
@mandubian
Copy link

No I think its the 3-levels-deep paths that pose problem!
Can you try something like ?

 implicit val reads: Reads[PostedMessage] = (
(__ \ "_id").read[String] ~
(__ \ "@message").read[String] ~
(__ \ "_source \ "@fields").read( 
    (__ \ "CPAID").read[String] ~
    (__ \ "frompartyid").read[String] ~
    (__ \ "topartyid").read[String] ~
    (__ \ "CONVERSATIONID").read[String] ~
    (__ \ "msgId").read[String] ~
    (__ \ "action").read[String] ~
    (__ \ "service").read[String]
    tupled
)
){ case (id, message, (cpaid, from, to, conv, msgid, action, service)) => PostedMessage.apply(...) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment