groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Kleeh <>
Subject 2.5 JsonBuilder Converters thoughts
Date Tue, 25 Oct 2016 19:07:38 GMT
Currently if one were to register a converter with options like so:

JsonGenerator.Options options = new JsonGenerator.Options()
options.addConverter(MyCustomType) { MyCustomType mct ->

Assuming “” returns a string, it will be output without quotes because of:

Converter converter = findConverter(objectClass);
if (converter != null) {
    writeRaw(converter.convert(object, key), buffer);

I’d be curious to hear what the use case is for outputting the data as raw. I think the
percentage of users that would prefer to have their data further processed by that method
would vastly outnumber the ones that do not.

I think something like this would be a better solution:

Converter converter = findConverter(objectClass);
if (converter != null) {
    object = converter.convert(object, key);


James Kleeh
View raw message