users@jsonp.java.net

Re: JsonWriter is missing flush() method

From: Jitendra Kotamraju <jitendra.kotamraju_at_oracle.com>
Date: Fri, 01 Nov 2013 12:13:40 -0700

On 11/1/13 1:02 AM, Hildeberto Mendonça wrote:
> Hi Jitu,
>
> Please, take into consideration that people who work with XML today may consider migrating to Json. For that, they need an API that is rich enough to deal with the problems they have. Therefore, they will probably miss the flush() method because you can find this method in the XML Stream API (http://docs.oracle.com/javase/7/docs/api/javax/xml/stream/XMLStreamWriter.html) There are algorithms out there that need it.
The equivalent XMLStreamWriter is JsonGenerator in the API. It
implements Flushable interface.
JsonWriter is for writing already created object models. If the single
write method already writes the entire contents, then I don't see any
need for explicit flush() method.
>
> Even Json for .net has it (http://james.newtonking.com/json/help/index.html?topic=html/AllMembers_T_Newtonsoft_Json_JsonWriter.htm) so you can not neglect it, because it just have to be there, period.
>
> I’m sure you can find it in many other APIs, so Jsonp cannot fall behind for so long.
>
> On 01 Nov 2013, at 00:36, Jitendra Kotamraju <jitendra.kotamraju_at_oracle.com> wrote:
>
>> On 10/31/13 12:17 PM, Jitendra Kotamraju wrote:
>>> That should have worked esp when you are creating JsonWriter using a i/o Writer. JsonWriter.write() method writes all the contents to underlying writer. The recent releases don't use BufferedWriter. Are you using the latest version i.e. 1.3 or 1.4-SNAPSHOT ?
>>>
>>> But if you create JsonWriter with byte stream, then that doesn't work. Internally, it uses
>> I fixed this for byte streams also. So, JsonWriter#write methods would write all the buffered contents to given output source.
>>