Re: [JSON] object-based JSON vs. triple-based JSON

On 10/03/11 01:35, Manu Sporny wrote:
...
> Now imagine that we could pass arguments to the parser, things like:
>
> EXPAND_IRI
>     Expands all Terms/CURIEs into full IRIs
> REMOVE_MICROSYNTAX_MARKUP
>    Removes any Microsyntax markup so that values can be used more
>    directly
> COMPACT_IRI
>    Directs the parser to use a mapping we provide to shorten IRIs
>
> Now assume this input (jsonldText):
>
> {
>     "#":
>     {
>        "name": "http://xmlns.com/0.1/foaf/name",
>        "foo": "http://example.com/vocab#foo"
>        "ex": "http://example.com/v#"
>     },
>     "name": "nathan",
>     "foo": "bar^^<ex:baz>"
> }
>
> If we wanted to make sure the IRIs were always expanded, we could do this:
>
> var obj = RDFinJSON.parse(jsonldText, EXPAND_IRI);
>
> which would give us this:
>
> {
>     "<http://xmlns.com/0.1/foaf/name>": "nathan",
>     "<http://example.com/vocab#foo>": "bar^^<http://example.com/v#baz>"
> }
>
> If we wanted to ensure that there is no nasty microsyntax markup, we
> could do this:
>
> var obj = RDFinJSON.parse(jsonldText, REMOVE_MICROSYNTAX_MARKUP);
>
> which would give us this:
> {
>     "name": "nathan",
>     "foo": "bar"
> }
>
> If we wanted to make sure there was no nasty microsyntax markup and that
> all IRIs were expanded, we could do this (and perhaps this would be the
> default result of the .parse() method):
>
> var obj = RDFinJSON.parse(jsonldText, EXPAND_IRI |
>                                        REMOVE_MICROSYNTAX_MARKUP);
>
> which would give us this:
> {
>     "http://xmlns.com/0.1/foaf/name": "nathan",
>     "http://example.com/vocab#foo": "bar"
> }
>
> If we wanted to remap "name" and "foo" to "fn" and "fo" respectively, we
> could provide a developer-specified mapping:
>
> var mappings =
> {
>     "foaf": "http://xmlns.com/0.1/foaf/",
>     "fo": "http://example.com/vocab#foo"
> };
> var obj = RDFinJSON.parse(jsonldText, COMPACT_IRI |
>                                        REMOVE_MICROSYNTAX_MARKUP,
>                            mappings);
>
> would give us this:
> {
>     "foaf:name": "nathan",
>     "fo": "bar"
> }

For my understanding:

Does this mean we would defining both an on-the-wire form ("jsonldText") 
and the data structure ("obj")?  Presumable related but "obj" is simpler?

What would a graph look like?

 Andy

Received on Thursday, 10 March 2011 08:35:18 UTC