Skip to content

Instantly share code, notes, and snippets.

@afsalthaj
Created June 29, 2018 06:50
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 afsalthaj/67259a39c54dc7ae897a35882ff94288 to your computer and use it in GitHub Desktop.
Save afsalthaj/67259a39c54dc7ae897a35882ff94288 to your computer and use it in GitHub Desktop.
case class Something(value: Int)
// We have implicit EncodeJson available for Int.
def toJson(a: Int) = EncodeJson[Int].toJson(a)
def toJson(a: Something): EncodeJson[Something] =
EncodeJson[Int].contramap { _.value }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment