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: 591
  • 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 1215 - 1244 of 1955   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Show Message Summaries Sort by Date ^  
#1215 From: Tatu Saloranta <tsaloranta@...>
Date: Mon Feb 16, 2009 7:51 pm
Subject: Re: Re: JSONRequest
cowtowncoder
Send Email Send Email
 
On Mon, Feb 16, 2009 at 12:10 AM, pigwin32 <pigwin32@...> wrote:
> --- In json@yahoogroups.com, "Douglas Crockford" <douglas@...> wrote:
>>
>> I am proposing a new mechanism for doing data transport in Ajax/Comet
>> applications. It is called JSONRequest. It is a minimal communications
>> facility that can be exempted from the Same Origin Policy.
>>
>> You can read about it here: http://json.org/JSONRequest.html
>>
>
> This question may have been asked previously but a quick search didn't
> turn up anything. Why does JSONRequest only support GET/POST and
> propose a new CANCEL request? What of PUT and DELETE? I can see how
> JSONRequest would be extremely useful for RESTful web services and I'm
> curious as to why you are proposing yet another protocol on top of
> HTTP when HTTP already provides the necessary verbs and
> exceptions/error codes. Wouldn't it be expedient to work within the
> existing HTTP specification? My apologies if this has already been
> addressed, I've arrived a little bit late to the discussion.

I am not a REST expert, but isn't PUT used to store given payload (in
this case, request in form of Json), and DELETE just ignore payload?
Meaning that such operations via JSONRequest wouldn't make much sense;
after all, you can call PUT with appropriate content type anyway, and
DELETE wouldn't require one.

That is: what would be useful semantics for such operations? (same
could be asked of GET -- but I assume that's for manual testing via
browser)

I guess case could be made that for completeness sake these verbs
should be supported.

-+ Tatu +-

#1216 From: "Jimmy Zhang" <jzhang2004@...>
Date: Wed Feb 18, 2009 8:35 pm
Subject: [ANN] VTD-XML 2.5 released
jzhang_ximpl...
Send Email Send Email
 
VTD-XML 2.5 is now released. Please go to
https://sourceforge.net/project/showfiles.php?
group_id=110612&package_id=120172&release_id=661376
   to download the latest version.


Changes from Version 2.4 (2/2009)

* Added separate VTD indexing generating and loading (see
http://vtd-xml.sf.net/persistence.html for further info)
* Integrated extended VTD supporting 256 GB doc (In Java only).
* Added duplicateNav() for replicate multiple VTDNav instances sharing
XML, VTD
and LC buffer (availabe in Java and C#).
* Various bug fixes and enhancements

#1217 From: Fang Yidong <fangyidong@...>
Date: Fri Feb 20, 2009 7:08 am
Subject: Performance of JSON libraries
fangyidong
Send Email Send Email
 
Hello Tatu,

While I was googling JSON.simple usage, I occasionally find
JsonSimpleDriver.java in svn of codehaus, and the benchmark results, comparing
with Jackson and other libraries. I think that it's your work?

The throughput of Jackson is high definitely and I really think Jackson is an
excellent StAX JSON parser.

I am writing to you because I'd like to share some of my opinions on the testing
itself. I know that you haven't pulished the results yet, here's just some
discussions.

Here's my opinions:
1. I think different libraries accept different inputs, such as a byte array, a
string, a inputstream or a reader, so the preparation of such input objects
should be prepared in the warm up stage, not the running.

2. I think the iteration of the resulting graph is not a part of the parser and
should not be put in the run method, but some minor operations can be performed
to verified that the result is a correct one.

3. Could you also help to test the SAX-like interface of JSON.simple in the way
of JacksonDriverStreaming.java did? 

I think your work will definitely help to improve the qualities of all JSON
libraries.

Thanks.

Yidong Fang




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

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

#1218 From: Fang Yidong <fangyidong@...>
Date: Fri Feb 20, 2009 7:14 am
Subject: Re: Performance of JSON libraries
fangyidong
Send Email Send Email
 
Sorry this message is intended to send to Tatu only. My bad.
Since the result is not published yet, let's discuss it privately.












             Hello Tatu,



While I was googling JSON.simple usage, I occasionally find JsonSimpleDriver.
java in svn of codehaus, and the benchmark results, comparing with Jackson and
other libraries. I think that it's your work?



The throughput of Jackson is high definitely and I really think Jackson is an
excellent StAX JSON parser.



I am writing to you because I'd like to share some of my opinions on the testing
itself. I know that you haven't pulished the results yet, here's just some
discussions.



Here's my opinions:

1. I think different libraries accept different inputs, such as a byte array, a
string, a inputstream or a reader, so the preparation of such input objects
should be prepared in the warm up stage, not the running.



2. I think the iteration of the resulting graph is not a part of the parser and
should not be put in the run method, but some minor operations can be performed
to verified that the result is a correct one.



3. Could you also help to test the SAX-like interface of JSON.simple in the way
of JacksonDriverStream ing.java did? 



I think your work will definitely help to improve the qualities of all JSON
libraries.



Thanks.



Yidong Fang




















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

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

#1219 From: Tatu Saloranta <tsaloranta@...>
Date: Fri Feb 20, 2009 7:46 am
Subject: Re: Performance of JSON libraries
cowtowncoder
Send Email Send Email
 
On Thu, Feb 19, 2009 at 11:08 PM, Fang Yidong <fangyidong@...> wrote:
> Hello Tatu,
>
> While I was googling JSON.simple usage, I occasionally find
JsonSimpleDriver.java in svn of codehaus, and the benchmark results, comparing
with Jackson and other libraries. I think that it's your work?

Hi there! Yes, that is true.

>
> The throughput of Jackson is high definitely and I really think Jackson is an
excellent StAX JSON parser.
>
> I am writing to you because I'd like to share some of my opinions on the
testing itself. I know that you haven't pulished the results yet, here's just
some discussions.

Sure, thank you for your input. I hadn't yet published it, but it is
of course public from the blog.

>
> Here's my opinions:
> 1. I think different libraries accept different inputs, such as a byte array,
a string, a inputstream or a reader, so the preparation of such input objects
should be prepared in the warm up stage, not the running.

Hmmh. I don't think I fully agree, but I agree in that it depends on use case.

For me, the use case is always getting Json from an external source
(network request, from file system), and hence input is naturally a
stream of bytes. So if a library just takes a String, it must be
constructed from bytes.
I did give shortcuts for some parsers so that there was no need to
read from the stream, so in a way some parsers benefited from the
setup (from my perspective).

It is possible that other use cases could be ones where a String would
be needed anyway (like perhaps reading it from a DB), but for me this
is not the case.

> 2. I think the iteration of the resulting graph is not a part of the parser
and should not be put in the run method, but some minor operations can be
performed to verified that the result is a correct one.

I think needs to be, because otherwise you can not do anything of use;
and parsers could optimize away some processing.
I don't think results would differ a lot though, most parsers do
handle all the data independent of traversal. I can probably make this
configurable to see what the difference is.

> 3. Could you also help to test the SAX-like interface of JSON.simple in the
way of JacksonDriverStreaming.java did?

Ah yes. Apologies for not trying it out -- I forgot that json.simple
does in fact have a streaming interface. I can add that, and make it
the main interface.

> I think your work will definitely help to improve the qualities of all JSON
libraries.

Thank you, and thanks for feedback!

-+ Tatu +-

#1220 From: Tatu Saloranta <tsaloranta@...>
Date: Fri Feb 20, 2009 5:12 pm
Subject: Re: Performance of JSON libraries
cowtowncoder
Send Email Send Email
 
On Thu, Feb 19, 2009 at 11:14 PM, Fang Yidong <fangyidong@...> wrote:
> Sorry this message is intended to send to Tatu only. My bad.
> Since the result is not published yet, let's discuss it privately.

(took the discussion offline, but if anyone is interested in what
results we are discussing, those are at:

http://www.cowtowncoder.com/blog/archives/2009/02/entry_204.html

I will be making some updates; and if any owners of other packages
have suggestions, let me know as well. Benchmarks are hard to do well
with different use cases and emphasis, so at least I want to document
presumptions and biases.

-+ Tatu +-

#1221 From: Alan Kennedy <alan@...>
Date: Sat Mar 21, 2009 12:18 pm
Subject: Announce: Jyson, a pure java JSON codec for jython 2.5.
alank1610
Send Email Send Email
 
Dear all,

I am pleased to announce the publication of a new open source product,
jyson, a pure java JSON codec for jython 2.5.

You can access source code, documentation, etc, for jyson here

http://jyson.xhaus.com

If you're wondering what benefit using jyson brings over other
available JSON codecs, please see the Jyson FAQ

http://opensource.xhaus.com/projects/jyson/wiki/JysonFaq

Regards,

Alan Kennedy.

#1222 From: "violinssoundcool" <violinssoundcool@...>
Date: Mon Mar 23, 2009 7:13 pm
Subject: JSON string possible escape character problem
violinssound...
Send Email Send Email
 
Hi.  I'm using JSON with JQGrid in an inquiry program.  I'm building a JSON
string with the server-side program, and the string contains an HTML hyperlink
tag.  Thus, the string should look something like this:

{"rows":[
{"divisionNumber":"4","divisionName":"<a
href=\"inv0004?productGroup=\"WFB\"&division=\"4\">MONTGOMERY - NEW
STEEL</a>","onHandWeight":"336660.28","percentOfTotal":"3.74","perLbCost":".45",\
"avgMonthlyWeight":"223615","monthsSupply":"3.37","turnoverRate":"4.69"}]}

This string works enough.  The link show up, but when I click on it, it takes me
to a URL of "inv0004?productGroup=".  Is there another character that needs to
be escaped?

#1223 From: "Stephen M. McKamey" <jsonml@...>
Date: Mon Mar 23, 2009 7:53 pm
Subject: Re: JSON string possible escape character problem
stephen.mckamey
Send Email Send Email
 
It's valid JSON but not HTML. You're effectively closing the href attribute with
the first \" in the URL.

First off, it's is going to be an issue because you're nesting unescaped quotes
in a quoted string.  To do that in a JSON string you'd need an extra backslash
to escape the backslash. '\"' becomes '\\"'.  But in HTML, you'd actually need
to encode a quote with '"e;'

But your next problem is URLs aren't supposed to have unescaped quotes.  You
should instead replace '\"' with '%22'.

It looks like the root of your issue is that you're using string concatenation
to build up your result rather than proper encoding.

--- In json@yahoogroups.com, "violinssoundcool" <violinssoundcool@...> wrote:
>
> Hi.  I'm using JSON with JQGrid in an inquiry program.  I'm building a JSON
string with the server-side program, and the string contains an HTML hyperlink
tag.  Thus, the string should look something like this:
>
> {"rows":[
> {"divisionNumber":"4","divisionName":"<a
href=\"inv0004?productGroup=\"WFB\"&division=\"4\">MONTGOMERY - NEW
STEEL</a>","onHandWeight":"336660.28","percentOfTotal":"3.74","perLbCost":".45",\
"avgMonthlyWeight":"223615","monthsSupply":"3.37","turnoverRate":"4.69"}]}
>
> This string works enough.  The link show up, but when I click on it, it takes
me to a URL of "inv0004?productGroup=".  Is there another character that needs
to be escaped?
>

#1224 From: Tatu Saloranta <tsaloranta@...>
Date: Mon Mar 23, 2009 8:14 pm
Subject: Re: Re: JSON string possible escape character problem
cowtowncoder
Send Email Send Email
 
On Mon, Mar 23, 2009 at 12:53 PM, Stephen M. McKamey <jsonml@...> wrote:
...
> It looks like the root of your issue is that you're using string concatenation
to build up your result rather than proper encoding.

This does seem to be the case, and if so, I agree that it's time to
use a proper json encoder.

Just as with xml, one should never use plain old string concatenation
for producing content. Sometimes it's necessary to create/edit json
(xml) by hand, but if it's done programmatically, proper tools should
be used.
Same goes for parsing, too, but most developers pick up that side more
easily. :)

-+ Tatu +-

#1225 From: "violinssoundcool" <violinssoundcool@...>
Date: Mon Mar 23, 2009 8:15 pm
Subject: Re: JSON string possible escape character problem
violinssound...
Send Email Send Email
 
You're totally right.  Wow.  I honestly can't believe I missed that.  I'm no
genius, but I didn't think I was a complete idiot until now.  I removed the
unnecessary quotes, and it works great now.  So, in the end, it looks like this:

{"rows":[
{"divisionNumber":"4","divisionName":"<a
href=\"inv0004?productGroup=WFB&division=4\">MONTGOMERY - NEW
STEEL</a>",...}]}

#1226 From: "violinssoundcool" <violinssoundcool@...>
Date: Mon Mar 23, 2009 8:16 pm
Subject: Re: JSON string possible escape character problem
violinssound...
Send Email Send Email
 
By the way, thanks for taking the time to respond to my post.

#1227 From: "Douglas Crockford" <douglas@...>
Date: Mon Mar 23, 2009 7:47 pm
Subject: Re: JSON string possible escape character problem
douglascrock...
Send Email Send Email
 
--- In json@yahoogroups.com, "violinssoundcool" <violinssoundcool@...> wrote:
>
> Hi.  I'm using JSON with JQGrid in an inquiry program.  I'm building a JSON
string with the server-side program, and the string contains an HTML hyperlink
tag.  Thus, the string should look something like this:
>
> {"rows":[
> {"divisionNumber":"4","divisionName":"<a
href=\"inv0004?productGroup=\"WFB\"&division=\"4\">MONTGOMERY - NEW
STEEL</a>","onHandWeight":"336660.28","percentOfTotal":"3.74","perLbCost":".45",\
"avgMonthlyWeight":"223615","monthsSupply":"3.37","turnoverRate":"4.69"}]}
>
> This string works enough.  The link show up, but when I click on it, it takes
me to a URL of "inv0004?productGroup=".  Is there another character that needs
to be escaped?


The string appears to be properly escaped from JSON's perspective. Your problem
lies elsewhere.

I think it is extremely unwise to pass strings received from the network into
innerHTML. That pattern is insecure.

#1228 From: "Stephen M. McKamey" <jsonml@...>
Date: Mon Mar 23, 2009 8:05 pm
Subject: Re: JSON string possible escape character problem
stephen.mckamey
Send Email Send Email
 
Sorry typo, that HTML quote entity should not have the e on the end: "

--- In json@yahoogroups.com, "Stephen M. McKamey" <jsonml@...> wrote:
>
> It's valid JSON but not HTML. You're effectively closing the href attribute
with the first \" in the URL.
>
> First off, it's is going to be an issue because you're nesting unescaped
quotes in a quoted string.  To do that in a JSON string you'd need an extra
backslash to escape the backslash. '\"' becomes '\\"'.  But in HTML, you'd
actually need to encode a quote with '"e;'
>
> But your next problem is URLs aren't supposed to have unescaped quotes.  You
should instead replace '\"' with '%22'.
>
> It looks like the root of your issue is that you're using string concatenation
to build up your result rather than proper encoding.
>
> --- In json@yahoogroups.com, "violinssoundcool" <violinssoundcool@> wrote:
> >
> > Hi.  I'm using JSON with JQGrid in an inquiry program.  I'm building a JSON
string with the server-side program, and the string contains an HTML hyperlink
tag.  Thus, the string should look something like this:
> >
> > {"rows":[
> > {"divisionNumber":"4","divisionName":"<a
href=\"inv0004?productGroup=\"WFB\"&division=\"4\">MONTGOMERY - NEW
STEEL</a>","onHandWeight":"336660.28","percentOfTotal":"3.74","perLbCost":".45",\
"avgMonthlyWeight":"223615","monthsSupply":"3.37","turnoverRate":"4.69"}]}
> >
> > This string works enough.  The link show up, but when I click on it, it
takes me to a URL of "inv0004?productGroup=".  Is there another character that
needs to be escaped?
> >
>

#1229 From: Andy Chu <andy@...>
Date: Thu Apr 9, 2009 7:54 pm
Subject: New 'JSON Template' language
andychup
Send Email Send Email
 
I'd like to solicit feedback on this minimal (but powerful) template
language I wrote:

http://code.google.com/p/json-template/

It's meant to be a language-independent specification for formatting JSON
data, as JSON is a language-independent data format.  Currently there are
Python, JavaScript, and Java implementations.

This article explains that it's meant to be the *complement* of JSON -- a
declarative/functional way to turn machine-readable data (JSON) into
human-readable data:

http://json-template.googlecode.com/svn/trunk/doc/Introducing-JSON-Template.html

I'm also interested in the "mashups" or "web service coordination" problem,
and this suggested architecture lends itself well to the problem.

The project was just made public last week, so it's fairly new.  But I think
the language has withstood the test of a decent amount of public scrutiny,
and the code is solid and well-tested.  I would appreciate any feedback,
either here or in the group: http://groups.google.com/group/json-template

thanks,
Andy


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

#1230 From: "mikeglaser@..." <mikeglaser@...>
Date: Sun Apr 19, 2009 5:04 am
Subject: Visual Basic 6 JSON Parser
mikeglaser...
Send Email Send Email
 
I have recently adapted a VBA Excel macro that parses multidimensional
JSON data (ie it deals with arrays and objects in the data), fixed some
parsing bugs and sped it up with a string builder class, and am
publishing this under the BSD license on my website:

http://www.ediy.co.nz/vbjson-json-parser-library-in-vb6-xidc55680.html

This should be useful for other Visual Basic 6 programmers. I would
appreciate any feedback or suggestions for improvements.




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

#1231 From: Tatu Saloranta <tsaloranta@...>
Date: Sat Apr 25, 2009 3:58 pm
Subject: Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)
cowtowncoder
Send Email Send Email
 
One thing that is currently missing (AFAIK) from JSON stack is the
equivalent of useful parts of W3C Schema ("xml schema").
I know there is a JSON Schema effort underway already, but if I
understand things correctly, its focus on validation aspects, and not
data typing or modeling .
Although w3c Schema can be used for that (as can DTDs and RelaxNG,
latter of which does this better), to me the main value of Schema is
as abstract data typing/model.

What I mean by this is that the only real advantage of, say, SOAP over
similar simpler JSON+Rest approach is that of having language-agnostic
data model that can be used for full object binding and serialization;
including code generation if need be. You can (painfully) define such
model, and then generate or bind conforming data to objects.
This helps in interoperability as you can describe data content in
language+platform independent way, but with ability to get specific
bindings reliably.
With JSON you can already do data mapping/binding quite well, except
for one area of problems: that of handling polymorphism (inheritance).
Although that can be worked around on language-by-language basis
(adding "class" element in Maps), there is no generic way to do it.

Another thing that I feel most existing Schema languages get wrong is
the false goal of having to be expressed in format being described
(XML schema written in xml). Instead, notation absolutely should be a
DSL: right tool for the job. This is especially crucial for JSON
because of its simplicity: trying to shoehorn a definition language in
JSON seems unnecessarily cumbersome.
It is ok to have a one-to-one mapping between optimal DSL and JSON (or
xml) if need be -- RelaxNG shows a good way of doing that with its
compact (non-xml) notation, and equivalent XML serialization.

So I would be interested in finding a solution for this problem -- it
seems like the last missing selling point for JSON-WS, to be used for
the use case of external entities communication over such an interface
(less needed for internal integration where more concrete interfaces,
client libs etc, can be used).

One more thing: defining such a notation might not be extremely
difficult -- since validation is NOT the main focus, range & size
limitations could be omitted, or kept very simple; more important is
JSON-primitive/object-inheritance data-typing and structural
definitions.
Validation aspects can be handled separately; or as an add-on.

-+ Tatu +-

#1232 From: John Cowan <cowan@...>
Date: Mon Apr 27, 2009 5:14 pm
Subject: Re: Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)
johnwcowan
Send Email Send Email
 
Tatu Saloranta scripsit:

> One thing that is currently missing (AFAIK) from JSON stack is the
> equivalent of useful parts of W3C Schema ("xml schema").

Very interesting.  I've been thinking about this a bit, and here's a
sketch of what I've come up with.  I'm assuming that the target language
looks like C++, Java, or C#: that is, objects have statically typed
members, there exists a subtyping relationship between types such that
a subtype has all the members of its supertypes, and Null (the type of
null) is a subtype of every object type.  Note that it doesn't matter
whether the language provides single or multiple inheritance.

In XML, data binding is based on the element name (for DTD-based systems)
or on the element name plus the types of ancestor elements (for W3C XML
Schema based systems).  JSON objects have no convenient analogue of the
element name, which is not only in a distinguished place in the element,
but is up front, making data binding on the fly practical.  We could just
require a "name" key in each object, but that would be IMHO against the
spirit of JSON.

So let's instead write down for each JSON object type a predicate that
identifies it.  Here's a tentative list of primitive predicates:

         isNull(keyName)
         isUndefined(keyName)
         isBoolean(keyName)
         isTrue(keyName)
         isFalse(keyName)
         isNumeric(keyName)
         hasNumericValue(keyName, number)
         hasStringValue(keyName, number)
         hasParentTypes(typename, ...)

The hasParentTypes predicate accepts an arbitrary number of type names,
which are in order the type of the parent object, the grandparent object, ....
This predicate is required for WXS-equivalent capability; omitting
it gives DTD-equivalent capability.  In addition, the usual and, or,
and not operators can be applied to construct complex predicates from
these primitives.  The type-assignment engine would have to validate
that no object can be assigned to more than one independent type.

In addition to the predicate, each type also has a set of key->type
mappings, which will be validated during type assignment.  The type in
such a mapping can be a primitive type (boolean, number), an object
type, an array type, or undefined.  So if a type specifies that key
x is boolean, then it must be so.  If it specifies that key y is of
type z, then we make sure the value of key y matches the predicate
for type z or any of the subtypes of z, or is null.  Arrays come in
four flavors: general arrays, boolean arrays, numeric arrays, and
arrays-of-object-type-x.  Undefined means that the key-value pair is
not represented in the object model.

We must have a lattice of subtype-supertype mappings.  For convenience,
it's probably best to specify in the mapping language one or more
supertypes for each type, with the understanding that the key->type
mappings of the supertype(s) are also assumed for the subtype.  This is
just a notational convenience, but OO programmers expect it.  In addition,
the subtype predicate as written is logically ANDed with the supertype
predicate(s) to form the effective predicate for the subtype.  This
hopefully preserves the Liskov substitution principle for the bound types.
This is the only exception to the rule that type predicates must be
independent.

Does this look like what you had in mind?

--
Her he asked if O'Hare Doctor tidings sent from far     John Cowan
coast and she with grameful sigh him answered that      http://ccil.org/~cowan
O'Hare Doctor in heaven was. Sad was the man that word  cowan@...
to hear that him so heavied in bowels ruthful. All
she there told him, ruing death for friend so young,    James Joyce, Ulysses
algate sore unwilling God's rightwiseness to withsay.   "Oxen of the Sun"

#1233 From: Tatu Saloranta <tsaloranta@...>
Date: Mon Apr 20, 2009 4:21 pm
Subject: JSON being used for Amazon Web Services new access policy language
cowtowncoder
Send Email Send Email
 
I thought this is interesting; as per these entries:

http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/SQSDeveloperG\
uide/index.html?AccessPolicyLanguage.html
http://cloudsecurity.org/2009/04/09/amazon-aws-introduces-new-access-policy-lang\
uage-sqs-today/

it looks like Amazon is defining its new access policy language (to be
used for most/all AWS services, and starting with the Simple Queue
Service, if I understand this correctly) to be based on JSON.
Neat.

-+ Tatu +-

#1234 From: John David Duncan <john.david.duncan@...>
Date: Mon Apr 27, 2009 5:36 pm
Subject: Re: Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)
jddefn
Send Email Send Email
 
Tatu,

I don't really understand XML schema or WSDL (which I think you're
referring to), so I could be quite off target here ...

but maybe Google Protocol Buffers fit the problem?

http://code.google.com/apis/protocolbuffers/docs/proto.html

JD



On Apr 25, 2009, at 8:58 AM, Tatu Saloranta wrote:

> One thing that is currently missing (AFAIK) from JSON stack is the
> equivalent of useful parts of W3C Schema ("xml schema").
> I know there is a JSON Schema effort underway already, but if I
> understand things correctly, its focus on validation aspects, and not
> data typing or modeling .
> Although w3c Schema can be used for that (as can DTDs and RelaxNG,
> latter of which does this better), to me the main value of Schema is
> as abstract data typing/model.
>
> What I mean by this is that the only real advantage of, say, SOAP over
> similar simpler JSON+Rest approach is that of having language-agnostic
> data model that can be used for full object binding and serialization;
> including code generation if need be. You can (painfully) define such
> model, and then generate or bind conforming data to objects.
> This helps in interoperability as you can describe data content in
> language+platform independent way, but with ability to get specific
> bindings reliably.
> With JSON you can already do data mapping/binding quite well, except
> for one area of problems: that of handling polymorphism (inheritance).
> Although that can be worked around on language-by-language basis
> (adding "class" element in Maps), there is no generic way to do it.
>
> Another thing that I feel most existing Schema languages get wrong is
> the false goal of having to be expressed in format being described
> (XML schema written in xml). Instead, notation absolutely should be a
> DSL: right tool for the job. This is especially crucial for JSON
> because of its simplicity: trying to shoehorn a definition language in
> JSON seems unnecessarily cumbersome.
> It is ok to have a one-to-one mapping between optimal DSL and JSON (or
> xml) if need be -- RelaxNG shows a good way of doing that with its
> compact (non-xml) notation, and equivalent XML serialization.
>
> So I would be interested in finding a solution for this problem -- it
> seems like the last missing selling point for JSON-WS, to be used for
> the use case of external entities communication over such an interface
> (less needed for internal integration where more concrete interfaces,
> client libs etc, can be used).
>
> One more thing: defining such a notation might not be extremely
> difficult -- since validation is NOT the main focus, range & size
> limitations could be omitted, or kept very simple; more important is
> JSON-primitive/object-inheritance data-typing and structural
> definitions.
> Validation aspects can be handled separately; or as an add-on.
>
> -+ Tatu +-
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>

#1235 From: Tatu Saloranta <tsaloranta@...>
Date: Mon Apr 27, 2009 6:17 pm
Subject: Re: Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)
cowtowncoder
Send Email Send Email
 
On Mon, Apr 27, 2009 at 10:14 AM, John Cowan <cowan@...> wrote:
> Tatu Saloranta scripsit:
>
>> One thing that is currently missing (AFAIK) from JSON stack is the
>> equivalent of useful parts of W3C Schema ("xml schema").
>
> Very interesting.  I've been thinking about this a bit, and here's a
> sketch of what I've come up with.  I'm assuming that the target language
> looks like C++, Java, or C#: that is, objects have statically typed

Exactly, since more dynamic languages can use "duck typing", or more
loose conversions. It's static languages that need extra help.

> members, there exists a subtyping relationship between types such that
> a subtype has all the members of its supertypes, and Null (the type of
> null) is a subtype of every object type.  Note that it doesn't matter

Yes. I don't think nulls should be typed; and probably only limitation there

> whether the language provides single or multiple inheritance.

Hmmh. I have to think about that a bit -- you may be right. I have
only considered single-inheritance case so far.

> In XML, data binding is based on the element name (for DTD-based systems)
> or on the element name plus the types of ancestor elements (for W3C XML
> Schema based systems).  JSON objects have no convenient analogue of the
> element name, which is not only in a distinguished place in the

True. But part of it is just "off by one" problem -- there's no name
at root level, but beyond this, there are field names that can be
mapped to schema contextually.

One thing I forgot to mention is that I am effectively using Java
objects as the schema: and there get/set methods and fields do have
names that you can match to JSON object property names (with
overriding by annotations or other configuration).
Same can not be done with explicit schema however, problem has to be
resolved differently like you explain.

> but is up front, making data binding on the fly practical.  We could just
> require a "name" key in each object, but that would be IMHO against the
> spirit of JSON.

Agreed, that seems wrong.

> So let's instead write down for each JSON object type a predicate that
> identifies it.  Here's a tentative list of primitive predicates:
>
>        isNull(keyName)

Would this mean it has to be null, or that it is nullable (allowsNull)?

>        isUndefined(keyName)

does this mean "any type"? Sort of fallback, xml "any" type.

>        isBoolean(keyName)
>        isTrue(keyName)
>        isFalse(keyName)
>        isNumeric(keyName)

perhaps also isInteger/integral?

>        hasNumericValue(keyName, number)
>        hasStringValue(keyName, number)

(string instead of 'number')

>        hasParentTypes(typename, ...)
>
> The hasParentTypes predicate accepts an arbitrary number of type names,
> which are in order the type of the parent object, the grandparent object, ....
> This predicate is required for WXS-equivalent capability; omitting
> it gives DTD-equivalent capability.  In addition, the usual and, or,
> and not operators can be applied to construct complex predicates from
> these primitives.  The type-assignment engine would have to validate
> that no object can be assigned to more than one independent type.

Yes.

> In addition to the predicate, each type also has a set of key->type
> mappings, which will be validated during type assignment.  The type in
...
> it's probably best to specify in the mapping language one or more
> supertypes for each type, with the understanding that the key->type
> mappings of the supertype(s) are also assumed for the subtype.  This is
> just a notational convenience, but OO programmers expect it.  In addition,
> the subtype predicate as written is logically ANDed with the supertype
> predicate(s) to form the effective predicate for the subtype.  This
> hopefully preserves the Liskov substitution principle for the bound types.
> This is the only exception to the rule that type predicates must be
> independent.
>
> Does this look like what you had in mind?

It sounds good so far, although I need to read this with more thought.
You have thought more deeply about hard problems than I have, I think. :)

Some additional constraints, compared to other schema work that I
thought of were:

- Not allowing union types that are not mappable to OO ("value can be
either an array or boolean"): this just means there are legal JSON
constructs for which no strict can be defined.
   This is in line with the idea of "schema" being geared towards
mapping to/from OO instances, not for constraining general JSON
content.

-+ Tatu +-

#1236 From: Tatu Saloranta <tsaloranta@...>
Date: Mon Apr 27, 2009 6:20 pm
Subject: Re: Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)
cowtowncoder
Send Email Send Email
 
On Mon, Apr 27, 2009 at 10:36 AM, John David Duncan
<john.david.duncan@...> wrote:
> Tatu,
>
> I don't really understand XML schema or WSDL (which I think you're
> referring to), so I could be quite off target here ...
>
> but maybe Google Protocol Buffers fit the problem?
>
> http://code.google.com/apis/protocolbuffers/docs/proto.html

I don't think it is directly applicable in PB, schema has much more
fundamental role, being mandatory for operating anything, and to
generate code (unless I'm mistaken). So in a way it is a strict
schema-first format. I am hoping for something that allows both
schema- and code-first approaches, somewhat similar to XML Schema in
that respect.

But maybe some aspects of PB might be useful: syntax, other ideas
regarding versioning?

-+ Tatu +-

#1237 From: John Cowan <cowan@...>
Date: Mon Apr 27, 2009 6:35 pm
Subject: Re: Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)
johnwcowan
Send Email Send Email
 
Tatu Saloranta scripsit:

> >        isNull(keyName)
>
> Would this mean it has to be null, or that it is nullable (allowsNull)?

All these predicates are on the JSON object itself, because they are used
before the object's type is known.  So isNull("foo") means that there
is a key "foo" in the JSON object value is null, and likewise with all
the other primitives.

> >        isUndefined(keyName)
>
> does this mean "any type"? Sort of fallback, xml "any" type.

No, it means that the specified key does not exist.  I use the name
"undefined" for cultural compatibility with JavaScript.  There would be
little point in an isAnyType predicate, because it would match anything
*except* a missing key.

> >        isNumeric(keyName)
>
> perhaps also isInteger/integral?

That's reasonable.  In that case it would be useful to be able to map
keys to integer as well, and perhaps standardized subtypes of integer too.

> - [U]nion types that are not mappable to OO ("value can be
> either an array or boolean"): this just means there are legal JSON
> constructs for which no strict can be defined.

Multiple inheritance is a subset of this (doesn't handle primitives).
If type foobar is a subtype of types foo and bar, then effectively it
is a union of them.

One question: should the predicates and the maps do on-the-fly conversion?
For example, if we specify a predicate of hasNumericValue("foo", 0),
does "foo": "0" match, or do we require "foo": 0?  Likewise, when
mapping, if the map specifies bar->String and the object contains
"bar": 123, does the bar field get "123", or is that an error?
These questions are independent.  I'd favor doing the conversions.

--
You let them out again, Old Man Willow!                 John Cowan
What you be a-thinking of?  You should not be waking!   cowan@...
Eat earth!  Dig deep!  Drink water!  Go to sleep!
Bombadil is talking.                                    http://ccil.org/~cowan

#1238 From: Kris Zyp <kriszyp@...>
Date: Mon Apr 27, 2009 9:25 pm
Subject: Re: Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)
kriszyp
Send Email Send Email
 
Tatu Saloranta wrote:
>
>
> One thing that is currently missing (AFAIK) from JSON stack is the
> equivalent of useful parts of W3C Schema ("xml schema").
> I know there is a JSON Schema effort underway already, but if I
> understand things correctly, its focus on validation aspects, and not
> data typing or modeling .
> Although w3c Schema can be used for that (as can DTDs and RelaxNG,
> latter of which does this better), to me the main value of Schema is
> as abstract data typing/model.

JSON Schema can certainly be used for that purpose, I am using JSON
Schema for typing in Dojo and Persevere, and not just for validating
existing JSON structures.

> What I mean by this is that the only real advantage of, say, SOAP over
> similar simpler JSON+Rest approach is that of having language-agnostic
> data model that can be used for full object binding and serialization;

I am not sure if this exactly what you are talking, but we have been
discussing using JSON Schema as a way to define hyperlink properties in
JSON structures to provide interoperability in RESTful JSON:
-------------------------------------

> including code generation if need be. You can (painfully) define such
> model, and then generate or bind conforming data to objects.
> This helps in interoperability as you can describe data content in
> language+platform independent way, but with ability to get specific
> bindings reliably.
> With JSON you can already do data mapping/binding quite well, except
> for one area of problems: that of handling polymorphism (inheritance).
> Although that can be worked around on language-by-language basis
> (adding "class" element in Maps), there is no generic way to do it.

The "extends" attribute of JSON Schema is designed specifically to meet
the needs of describing data structures with inheritance. Is this
insufficient for your polymorphic description needs?

> Another thing that I feel most existing Schema languages get wrong is
> the false goal of having to be expressed in format being described
> (XML schema written in xml). Instead, notation absolutely should be a
> DSL: right tool for the job. This is especially crucial for JSON
> because of its simplicity: trying to shoehorn a definition language in
> JSON seems unnecessarily cumbersome.
> It is ok to have a one-to-one mapping between optimal DSL and JSON (or
> xml) if need be -- RelaxNG shows a good way of doing that with its
> compact (non-xml) notation, and equivalent XML serialization.
>
> So I would be interested in finding a solution for this problem -- it
> seems like the last missing selling point for JSON-WS, to be used for
> the use case of external entities communication over such an interface
> (less needed for internal integration where more concrete interfaces,
> client libs etc, can be used).

"JSON-WS" hints more at RPC type communication, which is what SMD is
designed for (which uses JSON Schema):


> One more thing: defining such a notation might not be extremely
> difficult -- since validation is NOT the main focus, range & size
> limitations could be omitted, or kept very simple; more important is
> JSON-primitive/object-inheritance data-typing and structural
> definitions.
> Validation aspects can be handled separately; or as an add-on.

JSON Schema can as simple as the subset you want to use. {} is a valid
schema (although not particularly useful). We have discussed formally
defining a subset of JSON Schema for more traditional data-typing style
constraints, but when after some discussion of how easy it is to ignore
non-relevant parts of the spec, it seemed like kind of a silly exercise.
Of course, if you want to define a non JSON-based data type modeling
system, that is indeed a completely different matter and exercise. Or
maybe I am missing what you are really after.

Kris

#1239 From: Tatu Saloranta <tsaloranta@...>
Date: Tue Apr 28, 2009 5:55 am
Subject: Re: Need for "abstract data model" to support JSON, web services ("useful parts of w3c schema", not validation)
cowtowncoder
Send Email Send Email
 
On Mon, Apr 27, 2009 at 2:25 PM, Kris Zyp <kriszyp@...> wrote:
>
> Tatu Saloranta wrote:
>>
>> One thing that is currently missing (AFAIK) from JSON stack is the
>> equivalent of useful parts of W3C Schema ("xml schema").
...
>
> JSON Schema can certainly be used for that purpose, I am using JSON
> Schema for typing in Dojo and Persevere, and not just for validating
> existing JSON structures.

Ok. I did notice 'extends' property (but only after sending email),
which when combined with other pieces should allow for defining type
structures?

>> What I mean by this is that the only real advantage of, say, SOAP over
>> similar simpler JSON+Rest approach is that of having language-agnostic
>> data model that can be used for full object binding and serialization;
>
> I am not sure if this exactly what you are talking, but we have been
> discussing using JSON Schema as a way to define hyperlink properties in
> JSON structures to provide interoperability in RESTful JSON:

Basically I am thinking of supporting both schema-first model
(generaring classes/stubs from definition) and code first (annotating
to produce schema).
And for Java, perhaps generate bean-validation annotations, for schema
first case.

Perhaps what would be nice would be more along the lines of providing
more convenient syntax to express already defined json schema model.

...
> The "extends" attribute of JSON Schema is designed specifically to meet
> the needs of describing data structures with inheritance. Is this
> insufficient for your polymorphic description needs?

Probably not -- initially I just missed it. :-/

It does however need to be coupled with some definition of how to
include type identifier in json content ("#type" field? standard name,
or perhaps configurable with schema). Is there something in Json
schema to define this? Or if not, could it be added?
Type is needed to deserialize specific sub-type instance; on
serialization full type is known, but on deserialization only declared
type, and full type needs to be available from json content (can
optimize this out for leaf types).

...
> "JSON-WS" hints more at RPC type communication, which is what SMD is
> designed for (which uses JSON Schema):

True, I should have clarified that. This would be the data/type model
that is useful (and sort of required) for WS, but specifically not the
web service definition itself (no end points, operations etc defined).
Like XML Schema part that Soap/WSDL build on.

...
> JSON Schema can as simple as the subset you want to use. {} is a valid
> schema (although not particularly useful). We have discussed formally
> defining a subset of JSON Schema for more traditional data-typing style
> constraints, but when after some discussion of how easy it is to ignore
> non-relevant parts of the spec, it seemed like kind of a silly exercise.
> Of course, if you want to define a non JSON-based data type modeling
> system, that is indeed a completely different matter and exercise. Or
> maybe I am missing what you are really after.

Ok, thanks. Sub-setting could definitely work. I need to read json
schema proposal with some more thought. I am interested in syntax
part, as well as some limitations on what kinds of schemas would be
allowed -- certain kinds of unions might not be representable on OO
side.

Also: is the use of json as format for schema a fundamental goal? To
me it seems that there are benefits to using more compact and
expressive notation, but not much benefit from using JSON (i.e.
complexity is not within parsing of schema but in processing it).
I don't mind having a json serialization (RelaxNG - like "dual"
model), but really like the idea of having something more optimal for
the domain.

-+ Tatu +-

#1240 From: "W" <wayne.ivor@...>
Date: Tue Apr 28, 2009 8:28 am
Subject: JSWOOF - New JSON Parser For FLEX.
wain_mike
Send Email Send Email
 
Hi all,

I have been working on a new JSON Parser for FLEX.
Called JSWOOF.

The Library is fully complient with the JSON spec. and has
been fully optimized for fast encoding and decoding of streams.

you can find it at:
http://www.waynemike.co.uk/jswoof

#1241 From: Mark Ireland <markincuba@...>
Date: Tue Apr 28, 2009 12:06 am
Subject: RE: JSON being used for Amazon Web Services new access policy language
akaidr4vr
Send Email Send Email
 
Is there some advantage to using

"Action": ["SQS:SendMessage","SQS:ReceiveMessage"],

that I cant see?

Can I see an example of code getting keys and values from this (that shows why
it is a good structure)?

Thanks


To: json@yahoogroups.com
From: tsaloranta@...
Date: Mon, 20 Apr 2009 09:21:35 -0700
Subject: [json] JSON being used for Amazon Web Services new access policy
language


























       I thought this is interesting; as per these entries:



http://docs.amazonwebservices.com/AWSSimpleQueueService/2009-02-01/SQSDeveloperG\
uide/index.html?AccessPolicyLanguage.html

http://cloudsecurity.org/2009/04/09/amazon-aws-introduces-new-access-policy-lang\
uage-sqs-today/



it looks like Amazon is defining its new access policy language (to be

used for most/all AWS services, and starting with the Simple Queue

Service, if I understand this correctly) to be based on JSON.

Neat.



-+ Tatu +-




















_________________________________________________________________
Looking for a fresh way to share photos? Get the new Windows Live Messenger.
http://download.live.com/

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

#1242 From: Tatu Saloranta <tsaloranta@...>
Date: Tue Apr 28, 2009 5:23 pm
Subject: Re: JSON being used for Amazon Web Services new access policy language
cowtowncoder
Send Email Send Email
 
On Mon, Apr 27, 2009 at 5:06 PM, Mark Ireland <markincuba@...> wrote:
>
> Is there some advantage to using
>
> "Action": ["SQS:SendMessage","SQS:ReceiveMessage"],
>
> that I cant see?
>
> Can I see an example of code getting keys and values from this (that shows why
it is a good structure)?

That would be a question to ask Amazon Web Services developers...
it may have something to do with their existing systems and formats
(many xml based).

But at low level that's just a field with array value, and access
style depends on json library in use.

-+ Tatu +-

#1243 From: Martin Cooper <mfncooper@...>
Date: Tue Apr 28, 2009 6:23 pm
Subject: Re: JSWOOF - New JSON Parser For FLEX.
mfncooper
Send Email Send Email
 
On Tue, Apr 28, 2009 at 1:28 AM, W <wayne.ivor@...> wrote:

> Hi all,
>
> I have been working on a new JSON Parser for FLEX.
> Called JSWOOF.
>
> The Library is fully complient with the JSON spec. and has
> been fully optimized for fast encoding and decoding of streams.


Can you say some more about the way you tested performance against 'corelib'
(presumably as3corelib .92.1)? Apart from purely size, I'm interested in the
characteristics of the JSON structures you used (e.g. depth of nesting,
ratio of objects to arrays, object sizes, whitespace / density, etc.).

--
Martin Cooper


you can find it at:
> http://www.waynemike.co.uk/jswoof
>
>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>


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

#1244 From: "W" <wayne.ivor@...>
Date: Tue Apr 28, 2009 8:33 pm
Subject: Re: JSWOOF - New JSON Parser For FLEX.
wain_mike
Send Email Send Email
 
Testing was not done at a functional. For example i did not test my
string-encoding function against core-libs string-encoding function, etc. but
instead tested the overall speed of my encoding/decoding processes against
core-libs.

Strings where one area i found to have a serious impact on the processor, and
this was mainly due to the way the tokenizer was setting flag states. and the
way most parsers handle the strings in general. For example testing for
white-space in JSWOOF has no comparison tests, but instead uses bitwise
operations.

As for the rest of the encoding and decoding mechanism, it is handled
recursively, so a gain once becomes a gain over and over again. Each time that
optimized area gets called.

You asked about testing on arrays, and objects. But these are merely a
collection of sub entities [strings, number, Boolean, etc]. So density would
also only trigger execution of the same optimized sub-entity functions.

Wayne Mike.


--- In json@yahoogroups.com, Martin Cooper <mfncooper@...> wrote:
>
> On Tue, Apr 28, 2009 at 1:28 AM, W <wayne.ivor@...> wrote:
>
> > Hi all,
> >
> > I have been working on a new JSON Parser for FLEX.
> > Called JSWOOF.
> >
> > The Library is fully complient with the JSON spec. and has
> > been fully optimized for fast encoding and decoding of streams.
>
>
> Can you say some more about the way you tested performance against 'corelib'
> (presumably as3corelib .92.1)? Apart from purely size, I'm interested in the
> characteristics of the JSON structures you used (e.g. depth of nesting,
> ratio of objects to arrays, object sizes, whitespace / density, etc.).
>
> --
> Martin Cooper
>
>
> you can find it at:
> > http://www.waynemike.co.uk/jswoof
> >
> >
> >
> >
> >
> > ------------------------------------
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
>
>
> [Non-text portions of this message have been removed]
>

Messages 1215 - 1244 of 1955   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