Details
-
Type:
New Feature
-
Status:
Closed
-
Priority:
Minor
-
Resolution: Duplicate
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
(suggested by Dimitri M on user list)
There are use cases where it'd be good to be able to feed input to parser, instead of trying to provide an input stream for parser to read from. This would cover use cases where input comes in chunks; for example, part of logical document in one chunk, then after a delay (perhaps in a separate request) another one and so forth. In these cases it may be difficult to implement InputStream (Reader etc) abstraction; instead, it would be better if application could feed (push) data to parser.
But if so, parser must be able to indicate cases where no data is YET available (but may become available).
This is similar to how Aalto Xml processor (http://www.cowtowncoder.com/hatchery/aalto/index.html) operatesd in its async mode. However, since Json is much simple format than xml, implementation might be simpler.
Based on my experiences with Aalto, implementation is a non-trivial thing however. One problem is that even UTF-8 decoding needs to be somewhat aware of chunk boundaries, so in the end a separate parser may be required: this because current parser uses blocking to handle these split cases. A smaller problem is that of indicating "not-yet-available" case – this can probably be handled by introducing a new member in JsonToken enumeration.
I would really, really like to see NIO-based parsing for JSON, as I'm working on a non-blocking project right now but I'm a bit stymied by the blocking nature of the library. This isn't just a "nice to have" but a showstopper if the parsing is done in the selector thread (which sometimes happens depending on how the application routes requests).
I think non-blocking apps on Java will be the big "thing" of this year, so it makes sense to start thinking about how non-blocking web apps will processing incoming JSON requests and send outgoing ones.
IMHO this should be a fairly high priority item if one wants to stay ahead of the curve.