Yeah I agree JsonOutput.unescaped allows the same flexibility without
compromising the most common use case.

Cheers

On Tue, Oct 25, 2016 at 10:32 PM, John Wagenleitner
<[email protected]> wrote:
> On Tue, Oct 25, 2016 at 12:07 PM, James Kleeh <[email protected]> wrote:
>>
>> Currently if one were to register a converter with options like so:
>>
>> JsonGenerator.Options options = new JsonGenerator.Options()
>> options.addConverter(MyCustomType) { MyCustomType mct ->
>>     mct.name
>> }
>>
>>
>> Assuming “mct.name” returns a string, it will be output without quotes
>> because of:
>>
>> Converter converter = findConverter(objectClass);
>> if (converter != null) {
>>     writeRaw(converter.convert(object, key), buffer);
>>     return;
>> }
>>
>> 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);
>> }
>>
>> Thoughts?
>
>
>
> I had aimed for making it as flexible as possible and purposefully had it
> not participate in further processing to avoid surprises and be able to
> output JSON that otherwise wouldn't be possible due to the way the generator
> was already configured (nulls or being able to write out a number such as
> 9.3e7).
>
> I like your suggestion and think the flexibility could still be accomplished
> using JsonOutput.unescaped; and since 2.5 isn't out yet there's still time
> to refine how it works.
>
> I also would like to hear what others think.
>
> John



-- 
Graeme Rocher

Reply via email to