Can I get an InputStream that reads the serialization of an object?

873 views
Skip to first unread message

Benson Margulies

unread,
Aug 29, 2015, 7:06:14 PM8/29/15
to jackson-user
Is there any variation on ObjectWriter or ObjectMapper that gives me back an input stream that reads the json serialization of an object?

Tatu Saloranta

unread,
Sep 8, 2015, 2:57:24 PM9/8/15
to jackso...@googlegroups.com
Neither ObjectWriter nor ObjectMapper knows the input stream, but context object (DeserializationContext / SerializerProvider) may be able to do so.
They give access to the active JsonParser/JsonGenerator, which in turn have methods `getInputSource()` and `getOutputTarget()`.

-+ Tatu +-


On Sat, Aug 29, 2015 at 4:06 PM, Benson Margulies <ben...@basistech.com> wrote:
Is there any variation on ObjectWriter or ObjectMapper that gives me back an input stream that reads the json serialization of an object?

--
You received this message because you are subscribed to the Google Groups "jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jackson-user...@googlegroups.com.
To post to this group, send email to jackso...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Benson Margulies

unread,
Sep 8, 2015, 2:58:52 PM9/8/15
to jackso...@googlegroups.com
Tatu,

I didn't explain this very well.

Consider a method that accepts an InputStream. I want to start with a
Java object, and derive an InputStream that delivers the Json or
SMILE, so that I don't need to buffer the whole thing somewhere in
order to get an InputStream onto it.

Tatu Saloranta

unread,
Sep 8, 2015, 4:51:18 PM9/8/15
to jackso...@googlegroups.com
Ok, got it. There is no such functionality. And if you consider the impedance issue (push vs pull), it's unlikely this could be easily and efficiently implemented; serialization side is strictly based on use of Writer/OutputStream, and without features like co-processes (or whatever name this particularly language feature is) it is very difficult to implement in Java.

-+ Tatu +-

Raji Siloju

unread,
Jan 24, 2018, 7:16:45 PM1/24/18
to jackson-user
@Benson Margulies, were you able to solve this issue? I am trying to solve a similar problem. 
Reply all
Reply to author
Forward
0 new messages