- From: Tobie Langel <tobie.langel@gmail.com>
- Date: Fri, 8 Mar 2013 11:15:37 +0100
- To: Robin Berjon <robin@w3.org>
- Cc: whatwg@whatwg.org, David Rajchenbach-Teller <dteller@mozilla.com>
On Friday, March 8, 2013 at 10:44 AM, Robin Berjon wrote:
> On 07/03/2013 23:34 , Tobie Langel wrote:
> > Wouldn't some form of event-based API be more indicated? E.g.:
> >
> > var parser = JSON.parser();
> > parser.parse(src);
> > parser.onparse = function(e) { doSomething(e.data); };
>
>
> I'm not sure how that snippet would be different from a single callback API.
>
> There could possibly be value in an event-based API if you could set it
> up with a filter, e.g. JSON.filtered("$.*").then(function (item) {});
> which would call you for ever item in the root object. Getting an event
> for every information item that the parser processes would likely flood
> you in events.
Agreed, you need something higher-level than just JSON tokens. Which is why this can be very much app-specific, unless most of the use cases are to parse data of a format similar to [Object, Object, Object, ..., Object]. This could be special-cased so as to send each object to the event handler as it's parsed.
--tobie
Received on Friday, 8 March 2013 10:16:07 UTC