digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.66k stars 195 forks source link

Issue with compaction in playground #422

Open jaw111 opened 3 years ago

jaw111 commented 3 years ago

When I compact this input document:

{
  "@id": "http://example.com/this",
  "http://purl.org/dc/terms/date": "abc123"
}

Against this context:

{
  "@context": {
    "http://purl.org/dc/terms/date": {
      "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
    }
  }
}

The result is:

{
  "@context": {
    "http://purl.org/dc/terms/date": {
      "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
    }
  },
  "@id": "http://example.com/this",
  "http://purl.org/dc/terms/date": "abc123"
}

Which is the following when converted to N-Quads:

<http://example.com/this> <http://purl.org/dc/terms/date> "abc123"^^<http://www.w3.org/2001/XMLSchema#dateTime> .

In this case, one would expect the compacted result would be:

{
  "@context": {
    "http://purl.org/dc/terms/date": {
      "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
    }
  },
  "@id": "http://example.com/this",
  "http://purl.org/dc/terms/date": {
    "@value": "abc123"
  }
}