Representation of an empty indexed collection

Hello,

We have a small issue with serializing as JSON-LD a document that contain
an indexed collection in case the collection is empty but we would the
element to be part of the document.

This is our context definition:

    "@context": {
      "@base": "http://mabridge01/",
      "bridge": "https://confluence.nrk.no/display/RED/Ordbok#",
      "schema": "http://schema.org/",
      "jobId": "bridge:jobId",
      "data": {
        "@id": "bridge:data",
        "@container": "@index"
      }
    }

This is an example of a document with non-empty collection that is
correctly serialized:

{
    "@id": "http://mabridge01/api/v1/systems/bridge/jobs/statuses/123",
    "jobId": "123",
  "data": {"a":"b" ,"b":"b"}
  }

Resulting compacted JSON-LD (I removed context for clarity):

{
  "@id": "api/v1/systems/bridge/jobs/statuses/123",
  "data": {
    "a": "b",
    "b": "b"
  },
  "jobId": "123"
}

And here's an example with an empty collection:

{
    "@id": "http://mabridge01/api/v1/systems/bridge/jobs/statuses/123",
    "jobId": "123",
  "data": {}
  }

Resulting compacted JSON-LD (with context removed):

{
  "@id": "api/v1/systems/bridge/jobs/statuses/123",
  "bridge:data": [],
  "jobId": "123"
}

As you see, as long as "data" element contains an empty object (or list, I
also tried that), it is not serialized as a dictionary, i.e. an indexed
collection. So there is no way to include in a document an empty container
of a type @index (unless its value is set to "null" but then it will be
removed from the resulting document). Is there a way to represent an empty
indexed container?

Thanks in advance

Vagif

Received on Tuesday, 1 July 2014 11:20:29 UTC