-
Notifications
You must be signed in to change notification settings - Fork 156
JSON-LD 1.1: method to require {"id": "uri"} resource compaction result #507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
A compaction flag seems pretty heavy-handed, and could have some unintended consequences. I'd rather see if there might be something that could be done on the term definition to handle this. Basically, it seems that if a term could be defined which would be selected for any kind of value that would not conflate the compaction semantics. Right now, term selection is based on container and type/language, and a term won't be selected unless it matches the attributes of a given value. Those attributes are also called into play when compacting. PR #510 addresses a similar concern where an empty list would not be compacted using a list term because it had no values to determine if it should compact for a given language or type. We might consider allowing I'm not advocating for this change myself, but I'd like to see how much support such a change might get. |
Agreed that a flag is probably overkill. A keyword in the context is sufficient for our use case at least, though it would be nice if it required a resource and fell through for literals so that it didn't select them in compaction (per discussion in #510)... Thus, something like:
(And a triple |
In the given example case, doesn't this happen since If so, this shape is under your control through the context, so just removing the In a more general case where IRIs and literals are mixed for the same property, the problem does remain. I think it can be alleviated by using a different term for the property + literal combo, but only if their type can be predicted. Otherwise, the "elastic problem" might have to be solved using some new mechanism, so that the value is always an object, even for plain literals (i.e. given with a (Note that while compaction does not (IIRC) provide this option, it is valid JSON-LD to give plain literals as objects with a |
Agree that removing the It would also not be "backwards compatible" with other data produced using the context before the change, which would be helpful if not essential. A separate keyword to control it would be expensive but fallback nicely to existing behavior. |
All mechanism to avoid compacting to a string form end up failing, because the compaction algorithm always attempts to do this, and the term selection process avoids selecting a term that doesn't match. In retrospect, conflating term selection and compaction results may be the issue, and we should have probably simply gone with the first term that matches the property URI without regard to the shape of the data (which would substantially simplify that logic, anyway). I think the next best thing we could do is to define something in the term definition that causes it to match any shape data, and simply avoid conflicting terms in the context. The
To address the compaction to string, we'd need to add yet something else to an expanded term definition, say Of course, I think we're straying pretty far from 1.0 now, and this is probably too consequential for a CG to do, and would be better for a JSON-LD 2.0 which probably needs a separate charter. The best course is probably going to be to rely on a certain amount of client flexibility, and simply rely on the untyped term definitions to accomplish this. |
👍
I think that's probably the case for 1.x. Do we have a |
We have |
Transfered to the WG: w3c/json-ld-api#6 |
Issue: The compaction algorithm prefers the most compact format, which for resources without relationships is a string containing the URI. This causes problems in systems that cannot handle arrays of mixed data types (for example ElasticSearch) when there are also resources that have relationships, resulting in both objects and strings in the same array.
For example:
would raise an error in Elastic.
Proposed solution: Provide a flag to the compaction algorithm to signal that the resulting JSON should always create objects for resources, even if there is only the URI available. This would instead render the example above as an array of objects:
The text was updated successfully, but these errors were encountered: