json-ld/json-ld.org — Issue #65: Handling of data that doesn't contain triples.
Author: davidlehn
Created: 2012-01-23 21:10:51+00:00
State: open
Labels: playground, spec-design, test-suite

We may want to define how the JSON-LD APIs handle data that doesn't contain any triples. A few corner cases are:

* []
* http://json-ld.org/playground/?json-ld=%5B%5D&frame=%7B%7D
* {}
* http://json-ld.org/playground/?json-ld=%7B%7D&frame=%7B%7D
* {"ex":[]}
* http://json-ld.org/playground/?json-ld=%7B%22ex%22%3A%5B%5D%7D&frame=%7B%7D
* {"ex":{}}
* http://json-ld.org/playground/?json-ld=%7B%22ex%22%3A%7B%7D%7D&frame=%7B%7D

If we are going to define how this type of data is processed we should add the above test cases.

"[]" is fairly unambiguous as there is no data at all. The playground conversions seem correct.

"{}" is just converted to "{}" for compacted and expanded output but normalized output adds a bnode ID.

"{"ex":[]}" is converted to {"ex":"[]"} for compacted and expanded output and normalized output adds a bnode ID. The TURTLE output has a bug where ex is set to "undefined".

"{"ex":{}}" is converted similar to the array version and the TURTLE output contains a "bnode property bnode" triple (is that a bug?).

The question here is if these conversions should remove content that would generate no triples. In all these cases the output could be set to "[]" for JSON-LD or nothing for TURTLE meaning no triple data was found. Would this be too confusing? I can see conversion from an object to an empty array to be annoying to handle in code. However, it also seems odd to output empty objects, properties, and triples that could be removed.