digitalbazaar / jsonld.js

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

Keyword alias defined by @id does not replaced when compactization #473

Open Yocote0111 opened 2 years ago

Yocote0111 commented 2 years ago
const doc = {
    "@context": {
        "@base": "http://example.org",
        "dcterms": "http://purl.org/dc/terms/",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "alias1": "dcterms:title",
        "alias2": {
            "@id": "dcterms:description",
            "@type": "xsd:string"
        }
    },
    "@id": "#book1",
    "dcterms:title": "book 1",
    "dcterms:description": "this is book 1"
}

await jsonld.compact(doc, doc["@context"])

expects

{
  "@context": ... ,
  "@id": "#book1",
  "alias2": "this is book 1", 
  "alias1": "book 1" 
}

but results in

{
  "@context": ... ,
  "@id": "#book1",
  "dcterms:description": "this is book 1",  // not replaced 
  "alias1": "book 1"  // replaced with alias
}

version : "jsonld": "^5.2.0"