Skip to main content

[json-processing-spec users] Re: convenient method to stringify json objects

  • From: Tatu Saloranta < >
  • To:
  • Subject: [json-processing-spec users] Re: convenient method to stringify json objects
  • Date: Sun, 8 Apr 2012 09:38:58 -0700

On Sat, Apr 7, 2012 at 2:19 PM, Christian Grobmeier 
< >
 wrote:
> On Sat, Apr 7, 2012 at 11:13 PM, Tatu Saloranta 
> < >
>  wrote:
>>> A possible implementation could be:
>>>
>>> JsonObject obj ...
>>>
>>> obj.write(new StreamingGenerator(OutputStream));
>>>
>>> or
>>>
>>> MemoryGenerator mg = new MemoryGenerator();
>>> obj.write(mg);
>>> System.out.println(mg.getResult());
>>>
>>> Or something like that.
>>>
>>> Is this whats in your mind?
>>
>> Right, this is one possibility. Another is to require external object
>> to combine the pieces. And perhaps there are others; but these seem
>> obvious ones.
>>
>> One benefit of method you describe above is that this way one could
>> create custom node types, and override serialization method.
>
> Yap. One drawback is, I need the getResult() method on MemoryGenerator
> but not on the StreamingGenerator.
> It somehow feels wrong: is it included in the Generator interface, is
> it understandable for most people but senseless in the
> StreamingGenerator. Isn't it there, people might get confused because
> they need to cast to MemoryGenerator to get their result.

Oh, sorry, actually I should have read the code better. I do not think
there should be 'getResut()', as much as write just resulting in
underlying destination getting JSON content written.
And then that destination is responsible for handling;
StringWriter.toString() or so forth.

-+ Tatu +-


[json-processing-spec users] convenient method to stringify json objects

Yusuke Yamamoto 04/07/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Tatu Saloranta 04/07/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Christian Grobmeier 04/07/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Tatu Saloranta 04/07/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Christian Grobmeier 04/07/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Tatu Saloranta 04/07/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Christian Grobmeier 04/07/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Tatu Saloranta 04/08/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Jörn Horstmann 04/07/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Tatu Saloranta 04/08/2012

[json-processing-spec users] Re: convenient method to stringify json objects

Jitendra Kotamraju 04/08/2012
 
 
Close
loading
Please Confirm
Close