Loading ...
Sorry, an error occurred while loading the content.

1208Re: [json] Stoppable SAX-like interface for streaming input of JSON text

Expand Messages
  • Mark Joseph
    Feb 7, 2009
    • 0 Attachment
      I was reading over the StAX specification and BEA provides
      licenses to the API, but that license prevents
      sublicenses. This means I as a vendor cannot provide my
      own implementation and license that to customers. So if
      I am reading that right what is the point of that
      standard?
      We at P6R provide JSON and XML tools (amoung others), but
      if the standard has restrictions on it then its not a real
      standard that we can use.

      Mark
      P6R, Inc


      On Thu, 5 Feb 2009 15:28:41 +0800 (CST)
      Fang Yidong <fangyidong@...> wrote:
      > Well, if I am right, the parser in your example is
      >essentially a lexer, with slightly higher abstraction.
      >
      > It's true that it's convenient to control in simple
      >case. But in a slightly more complex scenario, such as
      >retrieving data in some desired location (for example,
      >'/store/book[1]/title' in XPath expression), I don't
      >think the code using a SAX(-like) parser is much more
      >complex than using a StAX(-like) parser.
      >
      > Besides easier to pipeline, a SAX(-like) parser requires
      >smaller memory footprint and is faster, and the stoppable
      >SAX-like interface introduced by JSON.simple avoids the
      >drawback that a traditional SAX parser requires the
      >entire document to be parsed to get a simple data.
      >
      > I think different applications require different
      >abstraction levels. JSON.simple's stoppable SAX-like
      >interface provides a new option to the user. It's your
      >choice of adopting it or not.
      > 发件人: Tatu Saloranta <tsaloranta@...>
      > 主题: Re: [json] Stoppable SAX-like interface for
      >streaming input of JSON text
      > 收件人: json@yahoogroups.com
      > 日期: 2009,25,周四,1:22上午
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > On Tue, Feb 3, 2009 at 8:09 PM, Fang Yidong
      ><fangyidong@yahoo. com.cn> wrote:
      >
      >> JSON.simple introduces a simplified and stoppable
      >>SAX-like content handler to process JSON text stream.
      >>Please take a look if you are interested in it:
      >
      >>
      >
      >
      >
      > If you are interested in application code controlling
      >parsing, why not
      >
      > just use Stax(-like) pull interface? Code example given
      >would be quite
      >
      > a bit simpler with "pull" approach; essentially little
      >more than
      >
      > recursive descent, or with some interfaces, linear
      >iteration like:
      >
      >
      >
      > ---
      >
      > JsonParser jp = factory.createJsonP arser(input) ;
      >
      > JsonToken t;
      >
      >
      >
      > while ((t = jp.nextToken( )) != null) {
      >
      > if (t == JsonToken.FIELD_ NAME && "id".equals(
      >t.getCurrentName ())) {
      >
      > break;
      >
      > }
      >
      > }
      >
      > if (t != null) { // get value for the field
      >
      > t = jp.nextToken( );
      >
      > System.out.println( "found id, value: "+jp.getText( ));
      >
      > }
      >
      > ---
      >
      >
      >
      > And you could obviously built simpler abstractions for
      >matching on top of this.
      >
      >
      >
      > The main benefit of push-interface like SAX is that it
      >is easier to
      >
      > pipeline multiple processing stages. Otherwise it is
      >rather cumbersome
      >
      > and inconvenient way to process data that naturally
      >comes in
      >
      > well-defined and structured order.
      >
      >
      >
      > I am asking because oftentimes xml/json/whatever parser
      >writers use
      >
      > SAX-like approaches without knowing that it's only way
      >to slice and
      >
      > dice data, and often not the best.
      >
      >
      >
      > -+ Tatu +-
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      >
      > ___________________________________________________________
      > 好玩贺卡等你发,邮箱贺卡全新上线!
      > http://card.mail.cn.yahoo.com/
      >
      > [Non-text portions of this message have been removed]
      >

      -------------------------
      Mark Joseph, Ph.D.
      President and Secretary
      P6R, Inc.
      http://www.p6r.com
      408-205-0361
      Fax: 831-476-7490
      Skype: markjoseph_sc
      IM: (Yahoo) mjoseph8888
      (AIM) mjoseph8888
    • Show all 12 messages in this topic