У меня есть следующий список, который содержит семантические описания с идентификаторами.
const list = [{
semanticDescription: {
"@context": {
"schema": "https://schema.org/",
"fno": "https://w3id.org/function/ontology#"
},
"@graph": [
{
"@id": "Machine001",
"schema:potentialAction" : {
"@type": ["schema:PhotographAction", "fno:Function"],
"@id": "takePhoto"
}
},
{
"@id": "takePhoto",
"fno:expects": {
"@list": [{ "@id": "h" }, { "@id": "w" }]
},
"fno:returns": {
"@list": []
}
}]
},
identifier: 1
},
{
semanticDescription: {
"@context": {
"schema": "https://schema.org/",
"fno": "https://w3id.org/function/ontology#",
},
"@graph": [
{
"@id": "Machine001",
"schema:potentialAction" : {
"@type": ["schema:Transferaction", "fno:Function"],
"@id": "takePhoto"
}
},
{
"@id": "takePhoto",
"fno:expects": {
"@list": [{ "@id": "adress" }, { "@id": "postalCode" }]
},
"fno:returns": {
"@list": []
}
}]
},
identifier: 2
}
]
Как мне создать один файл JSON-LD, содержащий только описания semantic?
Я хочу вернуться в ответ на запрос GET, имеющий mimeType: 'jsonld'
.
ожидаемый допустимый вывод JSON-LD
Вот мой недействительный с дубликатами ключей output.jsonld
{
"@context": {
"schema": "https://schema.org/",
"fno": "https://w3id.org/function/ontology#"
},
"@graph": [
{
"@id": "Machine001",
"schema:potentialAction" : {
"@type": ["schema:PhotographAction", "fno:Function"],
"@id": "takePhoto"
}
},
{
"@id": "takePhoto",
"fno:expects": {
"@list": [{ "@id": "h" }, { "@id": "w" }]
},
"fno:returns": {
"@list": []
}
}],
"@graph": [
{
"@id": "Machine001",
"schema:potentialAction" : {
"@type": ["schema:Transferaction", "fno:Function"],
"@id": "takePhoto"
}
},
{
"@id": "takePhoto",
"fno:expects": {
"@list": [{ "@id": "adress" }, { "@id": "postalCode" }]
},
"fno:returns": {
"@list": []
}
}]
}
Есть ли способ получить файл JSON-LD, содержащий несколько объектов?