Re: Prefixes and the use of ':'

That works!
Thank you

On Fri, Sep 21, 2012 at 3:50 PM, Dave Longley <dlongley@digitalbazaar.com>wrote:

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


-- 
Dr. Paolo Ciccarese
http://www.paolociccarese.info/
Biomedical Informatics Research & Development
Instructor of Neurology at Harvard Medical School
Assistant in Neuroscience at Mass General Hospital
+1-857-366-1524 (mobile)   +1-617-768-8744 (office)

CONFIDENTIALITY NOTICE: This message is intended only for the addressee(s),
may contain information that is considered
to be sensitive or confidential and may not be forwarded or disclosed to
any other party without the permission of the sender.
If you have received this message in error, please notify the sender
immediately.

Received on Friday, 21 September 2012 19:59:49 UTC