jsr367-experts@jsonb-spec.java.net

[jsr367-experts] Re: [2-DefaultMapping] Proposal

From: Inderjeet Singh <inder_at_alumni.stanford.edu>
Date: Fri, 13 Mar 2015 15:42:55 -0700

>
> Get rid of toJson(..., writer), toJson(..., File) and toJson(...,
>>>> OutputStream)
>>>>
>>>
>>> File I don't care, but disagree for OS.
>>>
>>
>> In Gson, we don't provide support for InputStream/OutputStream. Not have
>> had a single person complain about it so far.
>> new InputStreamReader(inputStream) works fine. Same goes for OutputStream.
>>
>
> When wrapping a byte array it starts to get worse. Often I see brilliant
> code on SO where someone will take an inputstream and make a string of it
> (with 20 LOC) in order to then use a json lib to parse it. I hope that by
> providing this kind of methods it is more obvious that people can pass an
> inputstream to the API. But it is true they can wrap it. In first versions
> of Genson I followed the same logic and didn't provide methods for reading
> from a stream, added it later.
>

Can't make the API idiot-proof. The developer has the choice to use
InputStreamReader.
Converting an HTTP response it to a String is actually useful. I keep doing
it myself for debugging. Most APIs dont send a huge response anyway.

Inder