Created
February 15, 2018 17:59
-
-
Save kmizu/9b38282c6bdc59e422ae7a576162e9e8 to your computer and use it in GitHub Desktop.
SAM-convertible type and Function type
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
sbt.version=1.1.0 |
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
organization := "com.github.kmizu" | |
name := "play-json-example" | |
version := "0.1-SNAPSHOT" | |
scalaVersion := "2.12.4" | |
libraryDependencies += "com.typesafe.play" %% "play-json" % "2.6.7" |
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
package com.github.kmizu.play_json_example | |
import play.api.libs.json._ | |
object Main { | |
implicit class RichWrites[A](w: Writes[A]) { | |
def ignore(ignoreFields: String*): Writes[A] = { | |
w.transform{ | |
case JsObject(fields) => JsObject(fields.filterNot { | |
case (k, _) => ignoreFields.contains(k) | |
}) | |
case json => json | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment