How to exclude specific fields from being serialized when using the JsonOutput.toJson(..) in groovy?
Given class:
class Dummy {
String f1
transient String f2
}
Code:
// synthetic getter and setter should be preserved
Dummy dummy = new Dummy(f1: "hello", f2: "world")
String json = JsonOutput. toJson(dummy )
println json
Will result in:
{"f1":"hello", "f2":"world"}
Should result in:
{"f1":"hello"}