@java.lang.Deprecated(since = "7.1", forRemoval = true) public class JsonGenerator.Options extends groovy.json.JsonGeneratorOptions
A builder used to construct a JsonGenerator instance that allows
control over the serialized JSON output. If you do not need to customize the
output it is recommended to use the static JsonOutput.toJson methods.
Example:
def generator = new groovy.json.JsonGenerator.Options()
.excludeNulls()
.dateFormat('yyyy')
.excludeFieldsByName('bar', 'baz')
.excludeFieldsByType(java.sql.Date)
.build()
def input = [foo: null, lastUpdated: Date.parse('yyyy-MM-dd', '2014-10-24'),
bar: 'foo', baz: 'foo', systemDate: new java.sql.Date(new Date().getTime())]
assert generator.toJson(input) == '{"lastUpdated":"2014"}'