json-ld / json-ld.org

JSON for Linked Data's documentation and playground site
https://json-ld.org/
Other
859 stars 152 forks source link

Possibly missing text from the epilogue of the compaction algorithm? #608

Closed cwebber closed 6 years ago

cwebber commented 6 years ago

I found that some tests were not passing when an "empty" document (or document that had no nodes after compacting) compacted. I found that I needed to port over the following code from pyld:

        if (options['compactArrays'] and not options['graph'] and
                _is_array(compacted)):
            # simplify to a single item
            if len(compacted) == 1:
                compacted = compacted[0]
            # simplify to an empty object
            elif len(compacted) == 0:
                compacted = {}
        # always use an array if graph options is on
        elif options['graph']:
            compacted = JsonLdProcessor.arrayify(compacted)

While the epilogue to the compacting algorithm does mention some other adjustments, I don't think it mentions this. (Unless I am missing something?)

This exists both in the REC and current draft.

gkellogg commented 6 years ago

@cwebber do you recall what tests were failing without these steps?