Created
April 2, 2012 04:57
-
-
Save machisuji/2280858 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import play.api.libs.json._ | |
implicit object userToJson extends Writes[User] { | |
def writes(user: User): JsonValue = JsonObject(Seq( | |
"possiblyTotallyUnrelatedFieldName" -> JsString(user.name) | |
//, ... | |
)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I like this as a way to generate a loosely-coupled outbound message in situations where interpolation in a template (which are far easier to use to communicate what the message format is) exceeds performance requirements. Go type classes!