Skip to content

Instantly share code, notes, and snippets.

@glidester
Last active July 5, 2016 14:47
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 glidester/5348407c4e8668c304745c5371faadf2 to your computer and use it in GitHub Desktop.
Save glidester/5348407c4e8668c304745c5371faadf2 to your computer and use it in GitHub Desktop.
Example of excluding a field in Genson that is not working
import com.owlike.genson._
import com.owlike.genson.reflect.VisibilityFilter
import org.scalatest.WordSpecLike
case class TestEntity(name: String, date: Long, amount: Int)
class GensonSpec extends WordSpecLike {
val genson = new GensonBuilder()
.withBundle(ScalaBundle())
.useFields(true, VisibilityFilter.PRIVATE)
.useIndentation(true)
.exclude("amount")
.create()
"Genson" must {
"Test" in {
val jsonOut = genson.toJson( TestEntity("Hi",100L,10) )
println( jsonOut )
}
}
}
@glidester
Copy link
Author

STDOUT:

{
"amount":10,
"date":100,
"name":"Hi"
}

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