Skip to search.

Breaking News Visit Yahoo! News for the latest.

×Close this window

json · JSON JavaScript Object Notation

The Yahoo! Groups Product Blog

Check it out!

Group Information

  • Members: 590
  • Category: Data Formats
  • Founded: Jul 19, 2005
  • Language: English
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Messages

Advanced
Messages Help
Messages 1183 - 1212 of 1958   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#1183 From: "Stephen M. McKamey" <jsonml@...>
Date: Tue Dec 16, 2008 1:43 am
Subject: json2.js and Opera
stephen.mckamey
Send Email Send Email
 
It appears that versions of http://json.org/json2.js starting around
May 2008 have issues in Opera.  I've verified this in Opera 9.52 and
Opera 9.27.

The issue appears in the RegExp on line 190 of the 2008-11-19 version.
My guess is that Opera does not like escaped unicode in literal
RegExp?  It throws a syntax error which causes the rest of the script
to not load.

Does anyone know of a fix or work-around for this?

Thanks in advance,
smm

--- on Sat May 3, 2008 7:42 am, "Douglas Crockford" <douglas@...>
wrote:
>
> There are several Unicode characters that JavaScript mishandles,
> either by silent deletion, or by treating them as line ending
characters.
>
> json2.js now escapes those characters when it parses and when it
> minifies, so they can now be used correctly in JSON applications.
>
> http://www.JSON.org/json.js

#1184 From: Leen Besselink <leen@...>
Date: Tue Dec 16, 2008 10:50 am
Subject: Re: json2.js and Opera
leen@...
Send Email Send Email
 
On Tue, Dec 16, 2008 at 01:43:48AM -0000, Stephen M. McKamey wrote:
> It appears that versions of http://json.org/json2.js starting around
> May 2008 have issues in Opera.  I've verified this in Opera 9.52 and
> Opera 9.27.
>
> The issue appears in the RegExp on line 190 of the 2008-11-19 version.
> My guess is that Opera does not like escaped unicode in literal
> RegExp?  It throws a syntax error which causes the rest of the script
> to not load.
>
> Does anyone know of a fix or work-around for this?
>

Hi,

My college and me at work noticed this as well, we made a patch for
it at the time. It seems we forgot to report it. It's fixed in newer
versions of Opera.

--- json.js 2008/05/28 10:12:29 1.3
+++ json.js 2008/06/13 07:04:16 1.4
@@ -177,8 +177,8 @@
                   f(this.getUTCSeconds())   + 'Z';
          };

-        var cx =
/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u\
206f\ufeff\ufff0-\uffff]/g,
-            escapeable =
/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028\
-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
+        var cx = new
RegExp("[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u\
2060-\u206f\ufeff\ufff0-\uffff]", "g"),
+            escapeable = new
RegExp("[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200\
f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]","g"),
              gap,
              indent,
              meta = {    // table of character substitutions

> Thanks in advance,
> smm
>
> --- on Sat May 3, 2008 7:42 am, "Douglas Crockford" <douglas@...>
> wrote:
> >
> > There are several Unicode characters that JavaScript mishandles,
> > either by silent deletion, or by treating them as line ending
> characters.
> >
> > json2.js now escapes those characters when it parses and when it
> > minifies, so they can now be used correctly in JSON applications.
> >
> > http://www.JSON.org/json.js
>
_____________________________________
New things are always on the horizon.

#1185 From: "Stephen M. McKamey" <jsonml@...>
Date: Tue Dec 16, 2008 4:30 pm
Subject: Re: json2.js and Opera
stephen.mckamey
Send Email Send Email
 
Ahh, thanks!  I tried that but thought it didn't work because this
whole thing was masking a different Opera issue.  Your post made me go
back and look more closely.  Seems to do the trick.

Douglas, can you update json2.js to use the RegExp constructor syntax
instead of RegExp literals?

Thanks,
smm

--- In json@yahoogroups.com, Leen Besselink <leen@...> wrote:
>
> On Tue, Dec 16, 2008 at 01:43:48AM -0000, Stephen M. McKamey wrote:
> > It appears that versions of http://json.org/json2.js starting
around
> > May 2008 have issues in Opera.  I've verified this in Opera 9.52
and
> > Opera 9.27.
> >
> > The issue appears in the RegExp on line 190 of the 2008-11-19
version.
> > My guess is that Opera does not like escaped unicode in literal
> > RegExp?  It throws a syntax error which causes the rest of the
script
> > to not load.
> >
> > Does anyone know of a fix or work-around for this?
> >
>
> Hi,
>
> My college and me at work noticed this as well, we made a patch for
> it at the time. It seems we forgot to report it. It's fixed in newer
> versions of Opera.
>
> --- json.js 2008/05/28 10:12:29 1.3
> +++ json.js 2008/06/13 07:04:16 1.4
> @@ -177,8 +177,8 @@
>                   f(this.getUTCSeconds())   + 'Z';
>          };
>
> -        var cx = /[\u0000\u00ad\u0600-
\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-
\u206f\ufeff\ufff0-\uffff]/g,
> -            escapeable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-
\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-
\u206f\ufeff\ufff0-\uffff]/g,
> +        var cx = new RegExp("[\u0000\u00ad\u0600-
\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-
\u206f\ufeff\ufff0-\uffff]", "g"),
> +            escapeable = new RegExp("[\\\"\x00-\x1f\x7f-
\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-
\u202f\u2060-\u206f\ufeff\ufff0-\uffff]","g"),
>              gap,
>              indent,
>              meta = {    // table of character substitutions
>
> > Thanks in advance,
> > smm
> >
> > --- on Sat May 3, 2008 7:42 am, "Douglas Crockford" <douglas@>
> > wrote:
> > >
> > > There are several Unicode characters that JavaScript mishandles,
> > > either by silent deletion, or by treating them as line ending
> > characters.
> > >
> > > json2.js now escapes those characters when it parses and when it
> > > minifies, so they can now be used correctly in JSON
applications.
> > >
> > > http://www.JSON.org/json.js
> >
> _____________________________________
> New things are always on the horizon.
>

#1186 From: Fang Yidong <fangyidong@...>
Date: Wed Jan 7, 2009 3:36 am
Subject: New homepage for JSON.simple
fangyidong
Send Email Send Email
 
http://code.google.com/p/json-simple/

--
JSON: Action in AJAX!

JSON - http://www.json.org
JSON.simple - http://code.google.com/p/json-simple/


       ___________________________________________________________
   好玩贺卡等你发,邮箱贺卡全新上线!
http://card.mail.cn.yahoo.com/

#1187 From: "Tatu Saloranta" <tsaloranta@...>
Date: Wed Jan 7, 2009 5:12 pm
Subject: Re: New homepage for JSON.simple
cowtowncoder
Send Email Send Email
 
2009/1/6 Fang Yidong <fangyidong@...>:
>
> http://code.google.com/p/json-simple/

Quick question: home page suggests that one benefit of the library is
high performance. How is this determined, i.e. how has it been tested,
and against which libraries? For Java there are at least half a dozen
alternatives parsers, so it should be easy to find things to benchmark
against, I just didn't see a link that shows the details of testing
done.

-+ Tatu +-

#1188 From: Fang Yidong <fangyidong@...>
Date: Thu Jan 8, 2009 8:57 am
Subject: Re: New homepage for JSON.simple
fangyidong
Send Email Send Email
 
It's base on some internal testing and聽 testing of an independent author in
some complex scenarios.

The result show that the encoding of JSON.simple is as fast as Douglas's
implementation. The decoding is close to Douglas's implementation and faster
than some of the implementations, but slower than one or two of them.

The testing may not cover all scenarios and may not be completely fair, but
provides some basic information.

Hope there will be a public third party testing.

--

JSON: Action in AJAX!



JSON - http://www.json.org

JSON.simple - http://code.google.com/p/json-simple/














             2009/1/6 Fang Yidong <fangyidong@yahoo. com.cn>:

>

> http://code. google.com/ p/json-simple/



Quick question: home page suggests that one benefit of the library is

high performance. How is this determined, i.e. how has it been tested,

and against which libraries? For Java there are at least half a dozen

alternatives parsers, so it should be easy to find things to benchmark

against, I just didn't see a link that shows the details of testing

done.



-+ Tatu +-

























       ___________________________________________________________
   濂界帺璐哄崱绛変綘鍙戯紝閭璐哄崱鍏ㄦ柊涓婄嚎锛
http://card.mail.cn.yahoo.com/

[Non-text portions of this message have been removed]

#1189 From: "Tatu Saloranta" <tsaloranta@...>
Date: Thu Jan 8, 2009 5:20 pm
Subject: Re: New homepage for JSON.simple
cowtowncoder
Send Email Send Email
 
On Thu, Jan 8, 2009 at 12:57 AM, Fang Yidong <fangyidong@...> wrote:
> It's base on some internal testing and  testing of an independent author in
some complex scenarios.
>
> The result show that the encoding of JSON.simple is as fast as Douglas's
implementation. The decoding is close to Douglas's implementation and faster
than some of the implementations, but slower than one or two of them.
>
> The testing may not cover all scenarios and may not be completely fair, but
provides some basic information.
>
> Hope there will be a public third party testing.

Thank you for quick answer! Would it be maybe possible to publish
results of these internal tests? And/or maybe just cut'n paste your
explanation -- it helps a lot in understanding what has been measured.
For what it's worth, json.org's reference implementation is not among
the fastest parsers, but I guess it is a reasonable baseline to
compare against.

I can probably help with testing, too, since I do have a test suite I
have used previously (but not with json.simple since I didn't know of
its existence).

-+ Tatu +-

#1190 From: Fang Yidong <fangyidong@...>
Date: Sat Jan 10, 2009 8:35 am
Subject: Re: New homepage for JSON.simple
fangyidong
Send Email Send Email
 
It will be great if you can add JSON.simple (latest version 1.0.2) in your test
suite and let me know the results.

I'll publish the testing source codes and results if appropriate, later.
聽
Thanks.
聽
--
JSON: Action in AJAX!

JSON - http://www.json.org
JSON.simple - http://code.google.com/p/json-simple/

---






On Thu, Jan 8, 2009 at 12:57 AM, Fang Yidong <fangyidong@yahoo. com.cn> wrote:
> It's base on some internal testing and testing of an independent author in
some complex scenarios.
>
> The result show that the encoding of JSON.simple is as fast as Douglas's
implementation. The decoding is close to Douglas's implementation and faster
than some of the implementations, but slower than one or two of them.
>
> The testing may not cover all scenarios and may not be completely fair, but
provides some basic information.
>
> Hope there will be a public third party testing.

Thank you for quick answer! Would it be maybe possible to publish
results of these internal tests? And/or maybe just cut'n paste your
explanation -- it helps a lot in understanding what has been measured.
For what it's worth, json.org's reference implementation is not among
the fastest parsers, but I guess it is a reasonable baseline to
compare against.

I can probably help with testing, too, since I do have a test suite I
have used previously (but not with json.simple since I didn't know of
its existence).

-+ Tatu +-















       ___________________________________________________________
   濂界帺璐哄崱绛変綘鍙戯紝閭璐哄崱鍏ㄦ柊涓婄嚎锛
http://card.mail.cn.yahoo.com/

[Non-text portions of this message have been removed]

#1191 From: Tatu Saloranta <tsaloranta@...>
Date: Fri Jan 16, 2009 6:24 pm
Subject: Jackson home page moved to [http://jackson.codehaus.org]
cowtowncoder
Send Email Send Email
 
Doug, I realized that I hadn't sent you note about Jackson json
processor moving to Codehaus.
Could you update the link at json.org to point to:

http://jackson.codehaus.org

(the old page is still there and will redirect, so it's not a huge
deal, but eventually it'll move over completely)

Also: on a related note, would it make sense to start
classifying/grouping projects more on that page? Or adding some
tagging to indicate rough functionality. Right now level of json
functionality for Java libs varies a lot, for example: some libraries
are for xml processing but also expose interoperability functionality
for json; whereas others are json parsers, data binding packages and
so on.

-+ Tatu +-

#1192 From: "Douglas Crockford" <douglas@...>
Date: Fri Jan 16, 2009 9:26 pm
Subject: Re: Jackson home page moved to [http://jackson.codehaus.org]
douglascrock...
Send Email Send Email
 
--- In json@yahoogroups.com, Tatu Saloranta <tsaloranta@...> wrote:
>
> Doug, I realized that I hadn't sent you note about Jackson json
> processor moving to Codehaus.
> Could you update the link at json.org to point to:
>
> http://jackson.codehaus.org

Updated. Thanks.

> Also: on a related note, would it make sense to start
> classifying/grouping projects more on that page? Or adding some
> tagging to indicate rough functionality. Right now level of json
> functionality for Java libs varies a lot, for example: some libraries
> are for xml processing but also expose interoperability functionality
> for json; whereas others are json parsers, data binding packages and
> so on.

Would you like to propose something?

The Python community was able to converge on a single library. The
Java community has not yet, as far as I can tell, shown any intention
to converge.

#1193 From: Tatu Saloranta <tsaloranta@...>
Date: Fri Jan 16, 2009 9:58 pm
Subject: Re: Re: Jackson home page moved to [http://jackson.codehaus.org]
cowtowncoder
Send Email Send Email
 
On Fri, Jan 16, 2009 at 1:26 PM, Douglas Crockford
<douglas@...> wrote:
> --- In json@yahoogroups.com, Tatu Saloranta <tsaloranta@...> wrote:
>>
>> Doug, I realized that I hadn't sent you note about Jackson json
>> processor moving to Codehaus.
>> Could you update the link at json.org to point to:
>>
>> http://jackson.codehaus.org
>
> Updated. Thanks.

Thank you.

>> Also: on a related note, would it make sense to start
>> classifying/grouping projects more on that page? Or adding some
>
> Would you like to propose something?
>
> The Python community was able to converge on a single library. The
> Java community has not yet, as far as I can tell, shown any intention
> to converge.

I think convergence will happen via sort of natural selection over
time... although it might not be bad to have one or more APIs similar
to SAX/Stax. So for now it's ok to let all flowers bloom. :)

My suggestion would be more modest: to try to indicate what kind of
things libs are capable of, to help users more easily find what they
are looking for.
This is partly due to high number of json processing tools available
on java platform.

-+ Tatu +-

#1194 From: "Douglas Crockford" <douglas@...>
Date: Fri Jan 30, 2009 11:06 pm
Subject: JSON.stringify and inherited properties
douglascrock...
Send Email Send Email
 
The JSON.stringify function builds a JSON text using the own
properties of the objects it is given. If you want the text to also
include the inherited properties, then you can provide a replacer
function parameter that causes all of the members to be included. For
example,

JSON.stringify(n, function replacer(key, value) {
     var i, new_value;

     switch (typeof value) {
     case 'function':
     case 'undefined':
         return;
     case 'object':
         if (value &&
                 Object.prototype.toString.apply(value) !==
                      '[object Array]') {
             new_value = {};
             for (i in value) {
                 new_value[i] = value[i];
             }
             return new_value;
         }
         return value;
     default:
         return value;
     }
} , 4)

#1195 From: "terry_caton" <lc840c@...>
Date: Tue Feb 3, 2009 12:26 pm
Subject: New C++ JSON interface library
terry_caton
Send Email Send Email
 
Please check out my new C++ JSON interface library at:

http://cajun-jsonapi.sourceforge.net/

What makes it better than the others already available? A major goal
of the library was a powerful interface but a short learning curve.
The C++ Standard Template Library served as an inspiration for the
interface, and so should be immediately intuitive to anyone familiar
with the language. See the release notes for lots more information:

http://sourceforge.net/project/shownotes.php?
group_id=251569&release_id=658013


Cheers,
Terry

#1196 From: "Mark Joseph" <mark@...>
Date: Tue Feb 3, 2009 7:03 pm
Subject: Re: New C++ JSON interface library
markjoseph_sc
Send Email Send Email
 
Does this interface allow the JSON data to be streamed in?

Thanks,
Mark
P6R, Inc


On Tue, 03 Feb 2009 12:26:31 -0000
   "terry_caton" <lc840c@...> wrote:
> Please check out my new C++ JSON interface library at:
>
> http://cajun-jsonapi.sourceforge.net/
>
> What makes it better than the others already available?
>A major goal
> of the library was a powerful interface but a short
>learning curve.
> The C++ Standard Template Library served as an
>inspiration for the
> interface, and so should be immediately intuitive to
>anyone familiar
> with the language. See the release notes for lots more
>information:
>
> http://sourceforge.net/project/shownotes.php?
> group_id=251569&release_id=658013
>
>
> Cheers,
> Terry
>
>

-------------------------
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

#1197 From: Fang Yidong <fangyidong@...>
Date: Wed Feb 4, 2009 4:09 am
Subject: Stoppable SAX-like interface for streaming input of JSON text
fangyidong
Send Email Send Email
 
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:

http://code.google.com/p/json-simple/wiki/DecodingExamples#Example_5_-_Stoppable\
_SAX-like_content_handler


--
JSON: Action in AJAX!

JSON - http://www.json.org
JSON.simple - http://code.google.com/p/json-simple/


       ___________________________________________________________
   好玩贺卡等你发,邮箱贺卡全新上线!
http://card.mail.cn.yahoo.com/

#1198 From: json@yahoogroups.com
Date: Wed Feb 4, 2009 6:41 am
Subject: New file uploaded to json
json@yahoogroups.com
Send Email Send Email
 
Hello,

This email message is a notification to let you know that
a file has been uploaded to the Files area of the json
group.

   File        : /json-lib-1_0_2.zip
   Uploaded by : shawnsilverman <shawn@...>
   Description : A Java library for processing JSON data.

You can access this file at the URL:
http://groups.yahoo.com/group/json/files/json-lib-1_0_2.zip

To learn more about file sharing for your group, please visit:
http://help.yahoo.com/l/us/yahoo/groups/original/members/web/index.htmlfiles

Regards,

shawnsilverman <shawn@...>

#1199 From: "terry_caton" <lc840c@...>
Date: Wed Feb 4, 2009 2:21 pm
Subject: Re: New C++ JSON interface library
terry_caton
Send Email Send Email
 
--- In json@yahoogroups.com, "Mark Joseph" <mark@...> wrote:
>
> Does this interface allow the JSON data to be streamed in?
>

Yes it does. In fact, the library's built-in
input/output capability is based on the standard
istream & ostream classes, so any C++ stream-based
file/network/console interface should work automagically.
Furthermore, this stream-based serialization is
implemented "externally" via the visitor pattern,
which facilitates the straighforward implementation of
additional operations (graph rendering, document
validation, custom network streaming, etc).

#1200 From: Tatu Saloranta <tsaloranta@...>
Date: Wed Feb 4, 2009 5:22 pm
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
cowtowncoder
Send Email Send Email
 
On Tue, Feb 3, 2009 at 8:09 PM, Fang Yidong <fangyidong@...> 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.createJsonParser(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 +-

#1201 From: Fang Yidong <fangyidong@...>
Date: Thu Feb 5, 2009 7:28 am
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
fangyidong
Send Email Send Email
 
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]

#1202 From: Tatu Saloranta <tsaloranta@...>
Date: Thu Feb 5, 2009 5:41 pm
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
cowtowncoder
Send Email Send Email
 
On Wed, Feb 4, 2009 at 11:28 PM, Fang Yidong <fangyidong@...> wrote:
> Well, if I am right, the parser in your example is essentially a lexer, with
slightly higher abstraction.

Not really. You may want to read a bit on Stax API for Java: I assume
you are familiar with SAX API.
Both operate at roughly same level of abstraction, and handle parser
tasks of ensuring proper structure of the data format regarding
nesting (ordering of parsed tokens).

> 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.

That is debatable (I think event-handling approach is inherently less
intuitive personally, others disagree).
Path expressions can obviously run on either push or pull mode, so I
would agree in that convenience factor is not as big as when comparing
to higher abstractions (tree model, data binding).

But I was just pointing out that the example does not show much benefits.
So it would be good to showcase something where it does actually help?

Or perhaps it's just that json.simple exposes push interface and this
is an incremental improvement to the current way of doing this?

> Besides easier to pipeline, a SAX(-like) parser requires smaller memory
> footprint and is faster, and the stoppable SAX-like interface introduced by

No and no. Why would this be the case? Both are streaming, need to
keep limited amount of state. These are not true for xml pull vs push
parsers, and I haven't observed this with json parsers either
(including cases where a single parsers exposes both types of
interfaces).
My experience has been that in this regard approaches are roughly
equivalent, differences are between parsers, not between APIs.

> JSON.simple avoids the drawback that a traditional SAX parser requires the
> entire document to be parsed to get a simple data.

Right. That is a potentially useful incremental improvement. The
example pointed to made it sound like there were other benefits, or
that it was an optimal way of handling the task.
For what it's worth, push interface could be used to build a simple
solution too, just stop on match, don't worry about nesting etc. Or,
pull alternative changed to handle additional constraints.

> I think different applications require different abstraction levels.
JSON.simple's

But there is no different abstraction level here. Push (SAX) and pull
streaming interfaces work at same level of abstraction. Higher levels
would be tree models and data binding, both of which can be
implemented on top of either of these lower level approaches.

> stoppable SAX-like interface provides a new option to the user.
> It's your choice of adopting it or not.

Sure. But as part of advocating that, isn't it good to show why would
it make sense to use it?

As to stoppability of push parsing, the usual method so far has been
to throw an exception from the event handler. Would that not have
worked?

-+ Tatu +-

#1203 From: Fang Yidong <fangyidong@...>
Date: Fri Feb 6, 2009 12:52 am
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
fangyidong
Send Email Send Email
 
On Wed, Feb 4, 2009 at 11:28 PM, Fang Yidong <fangyidong@yahoo.
com.cn> wrote:

> > Well, if I am right, the parser in your example is essentially a lexer, with
slightly higher abstraction.



> Not really. You may want to read a bit on Stax API for Java: I assume

> you are familiar with SAX API.

> Both operate at roughly same level of abstraction, and handle parser

> tasks of ensuring proper structure of the data format regarding

> nesting (ordering of parsed tokens).


I did go through JSR 173 before comparing. I mean, the StAX parser in your
example is similar to a lexer such as org.json.simple.parser.Yylex:

Yylex lexer = new Yylex(in);
Yytoken token;
while((token = lexer.yylex()) != null){
   ...
}

But your StAX parser keeps the states so that the user is able to check if the
current token is a field name, while the lexer does not. So I said it's a higher
abstraction (over a lexer). But except the field name, other tokens (start/end
of a object, start/end of an array) are similar to ones that a lexer return.

Although it's quite low level, I agree it's good to standardize it and StAX has
its advantages in some applications.

> > 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.



> That is debatable (I think event-handling approach is inherently less

> intuitive personally, others disagree).

> Path expressions can obviously run on either push or pull mode, so I

> would agree in that convenience factor is not as big as when comparing

> to higher abstractions (tree model, data binding).



> But I was just pointing out that the example does not show much benefits.

> So it would be good to showcase something where it does actually help?



> Or perhaps it's just that json.simple exposes push interface and this

> is an incremental improvement to the current way of doing this?



> Besides easier to pipeline, a SAX(-like) parser requires smaller memory

> footprint and is faster, and the stoppable SAX-like interface introduced by



> No and no. Why would this be the case? Both are streaming, need to

> keep limited amount of state. These are not true for xml pull vs push

> parsers, and I haven't observed this with json parsers either

> (including cases where a single parsers exposes both types of

> interfaces).

> My experience has been that in this regard approaches are roughly

> equivalent, differences are between parsers, not between APIs.

I agree. I was using the data from JSON.simple's implementation to compare with
a StAX parser.

> JSON.simple avoids the drawback that a traditional SAX parser requires the

> entire document to be parsed to get a simple data.



> Right. That is a potentially useful incremental improvement. The

> example pointed to made it sound like there were other benefits, or

> that it was an optimal way of handling the task.

> For what it's worth, push interface could be used to build a simple

> solution too, just stop on match, don't worry about nesting etc. Or,

> pull alternative changed to handle additional constraints.



> > I think different applications require different abstraction levels.
JSON.simple' s



> But there is no different abstraction level here. Push (SAX) and pull

> streaming interfaces work at same level of abstraction. Higher levels

> would be tree models and data binding, both of which can be

> implemented on top of either of these lower level approaches.

I mean users may choose among DOM-like, SAX-like and StAX-like parsers.


> > stoppable SAX-like interface provides a new option to the user.

> > It's your choice of adopting it or not.



> Sure. But as part of advocating that, isn't it good to show why would

> it make sense to use it?



> As to stoppability of push parsing, the usual method so far has been

> to throw an exception from the event handler. Would that not have

> worked?

Not really. Here stoppable also means it's resumable. That is, the user can
pause at a point, doing other works, and then resume parsing or stop. Please
refer the example for detail:

http://code.google.com/p/json-simple/wiki/DecodingExamples#Example_5_-_Stoppable\
_SAX-like_content_handler

Actually, JSR 173(jsr173_07.pdf) argues it has advantages over SAX because:

One drawback to the SAX API is that the programmer must keep track of the
current
state of the document in the code each time they process an XML document and
thus cannot
iteratively process it. Another drawback to SAX is that the entire document
needs to be
parsed at one time.

The first drawback is partly true but in complex scenarios, a user with StAX
parser may also need to keep track of states such as nesting levels,
parent-child relationships and so on.

The purpose of JSON.simple's stoppable SAX-like interface is to help relieve
such issues.

Yidong Fang


       ___________________________________________________________
   好玩贺卡等你发,邮箱贺卡全新上线!
http://card.mail.cn.yahoo.com/

#1204 From: Tatu Saloranta <tsaloranta@...>
Date: Fri Feb 6, 2009 6:08 pm
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
cowtowncoder
Send Email Send Email
 
On Thu, Feb 5, 2009 at 4:52 PM, Fang Yidong <fangyidong@...> wrote:
>
>            On Wed, Feb 4, 2009 at 11:28 PM, Fang Yidong <fangyidong@yahoo.
com.cn> wrote:
>
>> > Well, if I am right, the parser in your example is essentially a lexer,
with slightly higher abstraction.

>> Not really. You may want to read a bit on Stax API for Java: I assume
>
> I did go through JSR 173 before comparing. I mean, the StAX parser in your
example is similar to a lexer such as org.json.simple.parser.Yylex:

Ah ok. Maybe I misread your comment: if you meant it's lower level of
abstraction than a tree model, yes.
I meant to say that SAX(-like) API is at similar level of abstraction
as Stax(-like).
...
> I mean users may choose among DOM-like, SAX-like and StAX-like parsers.

Ok yes, that makes sense.

(although DOM is technically not a parser but a tree model built on
top of that, but many users still call it a parser)

>> > stoppable SAX-like interface provides a new option to the user.
>
>> As to stoppability of push parsing, the usual method so far has been
>> to throw an exception from the event handler. Would that not have
>> worked?
>
> Not really. Here stoppable also means it's resumable. That is, the user can
pause at a point, doing other works, and then resume parsing or stop. Please
refer the example for detail:

Ok. That makes more sense then, thank you for pointing this out.

...
> Actually, JSR 173(jsr173_07.pdf) argues it has advantages over SAX because:
>
> One drawback to the SAX API is that the programmer must keep track of the
...
> iteratively process it. Another drawback to SAX is that the entire document
needs to be
> parsed at one time.
>
> The first drawback is partly true but in complex scenarios, a user with StAX
parser
> may also need to keep track of states such as nesting levels, parent-child
> relationships and so on.

Maybe, but not necessarily, because this information if implicit
within call stack (except for having to track end markers).
That is, it's a recursive-descent kind of approach where you know
where you came from, usually without additional tracking of location.
Code branches based on constructs encountered.

> The purpose of JSON.simple's stoppable SAX-like interface is to help relieve
such
> issues.

Ok.

-+ Tatu +-

#1205 From: Kris Zyp <kriszyp@...>
Date: Fri Feb 6, 2009 6:31 pm
Subject: JSON Query discussion group
kriszyp
Send Email Send Email
 
For those who might be interested, I have started new a Google
group/mailing list for the continued development of a language/syntax
for JSON querying:
http://groups.google.com/group/json-query

This group's purpose is to discuss, evolve, and create a specification
for JSON querying, building on existing designs to provide robust
comprehensive language for searching and retrieving information from
JSON-style object-oriented data structures.

The goals for the JSON Query language can be found at:
http://groups.google.com/group/json-query/web/json-query-requirements
and are listed below:

     * Build on JSONPath <http://goessner.net/articles/JsonPath/> - The
       most popular existing format for retrieving data from JSON
       structures is JSONPath. JSONPath has numerous implementations, and
       we wish to build on these.
     * Progressive operator evaluation -
           o Queries can be evaluated by left-to-right execution of
             operators, reducing the complexity of implementations.
           o The query language can be used a query format with URIs for
             RESTful querying of data. It should be possible to postpend
             a query to a URI to indicate a query into the data/resource
             referred by the URI.
           o The query syntax should be suitable as query component in
             the URI and provide alternate to
             application/x-www-form-urlencoded for encoding more complex
             queries. The query format could potentially be a MIME type
             application/jsonquery.
     * Maximize similarity with JavaScript/C-style syntax - JSON itself
       is a subset of JavaScript, and a JSON querying language should
       retain maximum interoperability with the language itself, with
       constructs that could potentially be included in future ECMAScript
       editions.
     * Language independence - The query language should have the
       semantics regardless of the underlying platform or framework.
     * Safely executable - It should be possible to evaluate queries from
       untrusted sources without undue risk of exposing oneself to
       security hazards.
     * Comprehensive querying capabilities:
           o Filter collections
           o Sorting results
           o Expressions with the ability to use object properties, array
             indexes, basic comparison operators, boolean operators, and
             finding matches within arrays.
           o Aggregate/group data and process it with collection
             reduction operations such as sum, maximum, minimum
           o Recursive search
           o Full text search
           o Create results of distinct sets, eliminating duplicates


     Current and Proposed Efforts

Efforts have been made to create a query language that meet the
requirements of this group with JSONQuery
<http://www.sitepen.com/blog/2008/07/16/jsonquery-data-querying-beyond-jsonpath/\
>,
which has been implemented in Dojo
<http://dojotoolkit.org/forum/dojox-dojox/dojox-grid-support/json-query>,
Persevere <http://docs.persvr.org/documentation/jsonquery>, and a
standalone JavaScript version
<http://github.com/JasonSmith/jsonquery/tree/master>. Other efforts
include Jaql <http://www.jaql.org/release/0.1/jaql-overview.html>, but
this does not meet the requirements of the specification. The current
JSONQuery syntax meets the majority of these goals but there are still
additional constructs that are needed for more comprehensive querying
capabilities. Missing capabilities include array matching, aggregation,
full text search, and distinct sets.


Thanks,
Kris


[Non-text portions of this message have been removed]

#1206 From: Tatu Saloranta <tsaloranta@...>
Date: Fri Feb 6, 2009 7:13 pm
Subject: Re: JSON Query discussion group
cowtowncoder
Send Email Send Email
 
Hi Kris! I think this is a good group to have. :)

One quick question: I was wondering about naming of the effort.

To me, "Path" and "Query" imply somewhat different (but overlapping)
feature sets:

* Path leaning towards traversal and selection of nodes, similar to
XPath, JsonPath
* Query seems more oriented towards aggregate operations (SQL, XQuery, Jaql)

Others may have different connotations with these terms.

But given the description of goals, it seems to me that the effort
would be more geared for defining a Path language, and not Query
language.

Am I totally off here? I just wonder if naming might lead people to
read too much into the effort; even if actual goals are clearly
listed.

-+ Tatu +-

#1207 From: Fang Yidong <fangyidong@...>
Date: Sat Feb 7, 2009 1:33 am
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
fangyidong
Send Email Send Email
 
> > The first drawback is partly true but in complex scenarios, a user with StAX
parser

> > may also need to keep track of states such as nesting levels, parent-child

> > relationships and so on.


> Maybe, but not necessarily, because this information if implicit

> within call stack (except for having to track end markers).

> That is, it's a recursive-descent kind of approach where you know

> where you came from, usually without additional tracking of location.

> Code branches based on constructs encountered.


Yes, it's convenient. But I think it may result in a call stack based processor
instead of a heap based one, right? The former will cause stack overflow issues
in a deep nesting level. Here's a heap based processor for building object graph
with SAX-like interface:

http://code.google.com/p/json-simple/wiki/DecodingExamples#Example_6_-_Build_who\
le_object_graph_on_top_of_SAX-like_content



       ___________________________________________________________
   好玩贺卡等你发,邮箱贺卡全新上线!
http://card.mail.cn.yahoo.com/

#1208 From: "Mark Joseph" <mark@...>
Date: Sun Feb 8, 2009 12:25 am
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
markjoseph_sc
Send Email Send Email
 
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

#1209 From: Tatu Saloranta <tsaloranta@...>
Date: Sun Feb 8, 2009 3:10 am
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
cowtowncoder
Send Email Send Email
 
On Sat, Feb 7, 2009 at 4:25 PM, Mark Joseph <mark@...> wrote:
> 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 don't see why you would need a license to implement an API.
Generally licensing governs usage of API itself, distributing it, modifying etc.
None of those are usually needed, because Stax is part of JDK 1.6.
Or you point users to download API jar itself from whoever can provide it.

Also: whatever stax specs download bundle claims is probably incorrect.

But yes, clearly BEA screwed up licensing mentions and other parts.

> 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.

Just to be clear: Stax API itself has little to do with Json. It is a
Java xml processing API, and would be of little help for Json. There's
no point in trying to implement it, due to fundamental differences
between xml and json data formats.

But similar style ("pull parsing") is useful.

-+ Tatu +-

#1210 From: Tatu Saloranta <tsaloranta@...>
Date: Sun Feb 8, 2009 3:16 am
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
cowtowncoder
Send Email Send Email
 
On Fri, Feb 6, 2009 at 5:33 PM, Fang Yidong <fangyidong@...> wrote:
>
>> Maybe, but not necessarily, because this information if implicit
>> within call stack (except for having to track end markers).
>
>> That is, it's a recursive-descent kind of approach where you know
>> where you came from, usually without additional tracking of location.
>> Code branches based on constructs encountered.
>
> Yes, it's convenient. But I think it may result in a call stack based
processor instead of a heap based
> one, right? The former will cause stack overflow issues in a deep nesting
level. Here's a heap

Yes, if your document has nesting level of about million or so. :-D
So I don't think that is a practical concern.

If it happens to be, then one can construct explicit stack, similar to
how one has to do it with SAX-like interfaces.

> based processor for building object graph with SAX-like interface:
>
http://code.google.com/p/json-simple/wiki/DecodingExamples#Example_6_-_Build_who\
le_object_graph_on_top_of_SAX-like_content

Right: that builds "poor man's object binding", List/Map/primitive
structure from Json.
Most Json parsers offer that functionality via API, so it need not be
built from low-level components (json.org and others).
Code with pull API would be quite similar, although one could choose
between recursion and iteration with explicit stack.

-+ Tatu +-

#1211 From: "Mark Joseph" <mark@...>
Date: Sun Feb 8, 2009 4:35 am
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
markjoseph_sc
Send Email Send Email
 
Ah I am sorry I was not clear we provide the JSON and XML
tools to C++ users not Java.
http://www.p6r.com/articles/2008/05/22/a-sax-like-parser-for-json/




On Sat, 7 Feb 2009 19:10:21 -0800
   Tatu Saloranta <tsaloranta@...> wrote:
> On Sat, Feb 7, 2009 at 4:25 PM, Mark Joseph
><mark@...> wrote:
>> 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 don't see why you would need a license to implement an
>API.
> Generally licensing governs usage of API itself,
>distributing it, modifying etc.
> None of those are usually needed, because Stax is part
>of JDK 1.6.
> Or you point users to download API jar itself from
>whoever can provide it.
>
> Also: whatever stax specs download bundle claims is
>probably incorrect.
>
> But yes, clearly BEA screwed up licensing mentions and
>other parts.
>
>> 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.
>
> Just to be clear: Stax API itself has little to do with
>Json. It is a
> Java xml processing API, and would be of little help for
>Json. There's
> no point in trying to implement it, due to fundamental
>differences
> between xml and json data formats.
>
> But similar style ("pull parsing") is useful.
>
> -+ Tatu +-

-------------------------
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

#1212 From: Tatu Saloranta <tsaloranta@...>
Date: Sun Feb 8, 2009 6:09 am
Subject: Re: Stoppable SAX-like interface for streaming input of JSON text
cowtowncoder
Send Email Send Email
 
On Sat, Feb 7, 2009 at 8:35 PM, Mark Joseph <mark@...> wrote:
> Ah I am sorry I was not clear we provide the JSON and XML
> tools to C++ users not Java.
> http://www.p6r.com/articles/2008/05/22/a-sax-like-parser-for-json/

Ok that explains it. I shouldn't have assume it's for Java either.
And it is true that for products that cover both xml and json, it is
advantageous to use same or similar interfaces too. There are some
java libraries that do something similar, such as jettison that
exposes json through java xml interfaces (stax in this case).

-+ Tatu +-

Messages 1183 - 1212 of 1958   Oldest  |  < Older  |  Newer >  |  Newest
Add to My Yahoo!      XML What's This?

Copyright 2010 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines NEW - Help