2015-08-03 15 views
5

Cách xác định một số thuộc tính là "tùy chọn" trong ngữ cảnh JSON-LD?Khung JSON-LD có thuộc tính tùy chọn?

Tôi đã tạo ví dụ đơn giản về sự cố. Đây là cùng một example in JSON-LD Playground. Đây là ví dụ dữ liệu:

{ 
    "@context": { 
    "ex": "http://example.org/ex#", 
    "foaf": "http://xmlns.com/foaf/0.1/", 
    "frapo": "http://purl.org/cerif/frapo/", 
    "owl": "http://www.w3.org/2002/07/owl#", 
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", 
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#", 
    "xsd": "http://www.w3.org/2001/XMLSchema#" 
    }, 
    "@graph": [ 
    { 
     "@id": "ex:Organization_1", 
     "@type": "foaf:Organisation", 
     "foaf:member": [ 
     { 
      "@id": "ex:Person_1" 
     }, 
     { 
      "@id": "ex:Person_2" 
     } 
     ], 
     "frapo:funds": [ 
     { 
      "@id": "ex:Project_1" 
     }, 
     { 
      "@id": "ex:Project_2" 
     } 
     ] 
    }, 
    { 
     "@id": "ex:Person_2", 
     "@type": "foaf:Person", 
     "foaf:currentProject": { 
     "@id": "ex:Project_2" 
     }, 
     "foaf:name": "Jack" 
    }, 
    { 
     "@id": "ex:Project_2", 
     "@type": "foaf:Project", 
     "foaf:name": "Small project 2" 
    }, 
    { 
     "@id": "ex:Project_1", 
     "@type": "foaf:Project", 
     "foaf:name": "Big project 1" 
    }, 
    { 
     "@id": "ex:Person_1", 
     "@type": "foaf:Person", 
     "foaf:name": "Bill", 
     "foaf:pastProject": [ 
     { 
      "@id": "ex:Project_1" 
     }, 
     { 
      "@id": "ex:Project_2" 
     } 
     ] 
    } 
    ] 
} 

tôi muốn tổ chức sẽ làm nút chính, chẳng hạn như:

foaf: Tổ chức

  • thành viên: [{Person}, {Person} ]

  • quỹ: [{Dự án}, {Dự án}]

Để tạo stucture như vậy tôi tạo ra khung:

{ 
"@context": { 
    "ex": "http://example.org/ex#", 
    "foaf": "http://xmlns.com/foaf/0.1/", 
    "owl": "http://www.w3.org/2002/07/owl#", 
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", 
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#", 
    "xsd": "http://www.w3.org/2001/XMLSchema#", 
    "frapo": "http://purl.org/cerif/frapo/" 
}, 
"@type": "foaf:Organisation", 
"foaf:member": { 
"foaf:currentProject": { 
    "@embed": false 
}, 
"foaf:pastProject": { 
    "@embed": false 
} 
}, 
"frapo:funds": {} 
} 

Bây giờ vấn đề là foaf: thành viên hóa ra là "vô giá trị", và nếu bạn loại bỏ những mối quan hệ dự án dự án được nhúng vào trong các trường hợp Person.

Trả lời

4

Hãy thử nó với khung này để thay thế:

{ 
    "@context": { 
     "ex": "http://example.org/ex#", 
     "foaf": "http://xmlns.com/foaf/0.1/", 
     "owl": "http://www.w3.org/2002/07/owl#", 
     "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", 
     "rdfs": "http://www.w3.org/2000/01/rdf-schema#", 
     "xsd": "http://www.w3.org/2001/XMLSchema#", 
     "frapo": "http://purl.org/cerif/frapo/" 
    }, 
    "@type": "foaf:Organisation", 
    "foaf:member": { 
     "foaf:currentProject": { 
      "@default": [], 
      "@embed": false 
     }, 
     "foaf:pastProject": { 
      "@default": [], 
      "@embed": false 
     } 
    }, 
    "frapo:funds": {} 
} 
+0

của nó làm việc ở sân chơi JSON-LD, nhưng không phải với thư viện JSON-LD-JAVA đối với một số lý do. – amiika

+0

Nhưng THANKS anyway, tôi đoán nó cũng nên làm việc với JSONLD-JAVA. – amiika

Các vấn đề liên quan