JSON-LD 1.1: method to require {"id": "uri"} resource compaction result · Issue #507 · json-ld/json-ld.org (original) (raw)
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:
"seeAlso": [
"http://example.org/reference1",
{"id": "http://example.org/reference2", "format": "text/html"}
]
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:
"seeAlso": [
{"id": "http://example.org/reference1"},
{"id": "http://example.org/reference2", "format": "text/html"}
]