Re: Modified curies for JSON (Re: JSON-LD normalization algorithm and MongoDB)

On 05/09/11 04:47, William Waites wrote:
> ] simply storing JSON-LD with all keys being ] CURIEs will avoid this
> issue, but it is worth noting that restriction.
> 
> One thing that I've seen done, which seems useful from the point of
> view of a Javascript programmer, is rather than express a CURIE as
> prefix:local to write it as prefix$local. The reason for this being
> that in Javascript, $ is a valid character as part of a name whereas
> : is not, enabling one to write,
> 
> person.foaf$name
> 
> instead of
> 
> person["foaf:name"]

You make a good point.

This has come up before in the RDFa Working Group and the RDF Web Apps
Working Group when working on the RDF Interfaces, RDF API and RDFa API.

The issue that we ran up against was that "$" makes sense to JavaScript
developers, but doesn't make much sense to other developers. That is,
"$" is a JavaScript-ism and may be confused with how one accesses
jQuery. I'm assuming that it is also a character that is unfamiliar to
the majority of the Semantic Web community, Python programmers, Ruby
developers, etc. "$" is also a reserved character in MongoDB. :P

The one strong argument in favor of "$" is that it isn't a reserved
character in JavaScript.

> is this small convenience enough to matter? I'm not sure. But I 
> thought I'd mention it.

We don't know if the convenience is enough to outweigh the downsides,
either :).

We tried to address this issue in the RDF API by providing an interface
called a "Projection" that would allow the developer to name the
properties in the object to whatever they want using a template:

http://www.w3.org/TR/2011/WD-rdfa-api-20110419/#projections

You can use a template to build a projection and use it like so (look
toward the very bottom):

http://www.w3.org/TR/2011/WD-rdfa-api-20110419/#advanced-concepts

This would allow you to access the variable in two ways:

1. obj["foaf:name"], or
2. obj.name

The down-side to this approach is that it requires an API to use
Projections:

http://json-ld.org/spec/ED/20110507/#methods

-- manu

-- 
Manu Sporny (skype: msporny, twitter: manusporny)
President/CEO - Digital Bazaar, Inc.
blog: PaySwarm Developer Tools and Demo Released
http://digitalbazaar.com/2011/05/05/payswarm-sandbox/

Received on Tuesday, 10 May 2011 18:48:51 UTC