ISSUE-40: Merge @coerce with @context

For those not attached to the issue tracker in GitHub, here's my recent comment (https://github.com/json-ld/json-ld.org/issues/40#issuecomment-2856559):

I just finished updating my implementation to accept both the old @coerce model as well as one of the proposed new models. Here are some observations:

Requiring that data typing always be done in the context of a term definition requires more terms to be defined. For example, I I just wanted to set a datatype of xsd:date on dc:date, I'd need to create a term for dc:date, which wouldn't otherwise be necessary. We may want to consider an alternate syntax that doesn't require a term be be created. More of a problem when serializing an existing RDF graph, where you may have some standard namespace definitions, but not terms.

I find the {"@iri": "foo", "@coerce": "xsd:date", "@list": true} notation to be in keeping with the overall style of JSON-LD. If the @iri is missing, I create an IRI for the term using the in-scope @vocab, which must be defined in a prior context. For example:

{
  "@context": [
    {"date": "http://www.w3.org/2001/XMLSchema#date", "term": "http://example.org/foo#"},
    {"foo": {"@iri": "term", "@coerce": "date"}}
  ],
  "foo": "bar"
}

Specifying that the term uses a list, just requires adding "@list": true to the object.

While using @coerce is correct, I think that in actual use, people may use @datatype here, as they would otherwise use @datatype when defining a literal. We should consider either replacing @coerce with @datatype, or allowing @datatype to act as an alias in this context.

The alternative of using objects with an IRI key seems shorter, but is less JSON-LD like.

For the time being, I'm going to accept either an @coerce block (with the previous dt: [prop] syntax) as well as the Object notation. I still need to update the serializer based on these rules.

Gregg

Received on Wednesday, 23 November 2011 23:52:41 UTC