Re: Prefixes and the use of ':'

On 09/21/2012 10:11 AM, Paolo Ciccarese wrote:
> Hello,
> I am trying to use JSON-LD for exchanging some content and I need to 
> be able to express namespaces.
> I was looking at example 33 in the spec: 
> http://json-ld.org/spec/FCGS/json-ld-syntax/20120626/
>
> If I use something like this
> {"foaf:age":"33"}
>
> I cannot access the value of that key - for instance in Grails/Groovy 
> or JavaScript - with something like:
> myobject.foaf:age
>
> In Grails/Groovy I have to change it into something like
> ((JSONObject) myobject).get("foaf:age");
>
> I was therefore wondering if you have any recommendations/preferred 
> approach for dealing with prefixes.
> I thought of just substituting the ':' with the '_' and then map all 
> the properties singularly in the context but it looks verbose and not 
> elegant.
>
> Thank you,
> Paolo
>
>

You can do:

myobject['foaf:age']

-- 
Dave Longley
CTO
Digital Bazaar, Inc.
http://digitalbazaar.com

Received on Friday, 21 September 2012 19:50:29 UTC