2015-08-03 38 views
5

Jak zdefiniować niektóre właściwości jako "opcjonalne" w kontekście JSON-LD?Wiązanie JSON-LD z opcjonalnymi właściwościami?

Stworzyłem prosty przykład problemu. Oto ten sam example in JSON-LD Playground. To jest przykład dane:

{ 
    "@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" 
     } 
     ] 
    } 
    ] 
} 

Chcę organizację jako główny węzeł, takich jak:

foaf: Organizacja

  • członkiem: [{Osoba}, {Osoba} ]

  • środki: [{Projekt} {projektowe}]

W celu stworzenia takiego stucture i stworzył ramy:

{ 
"@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": {} 
} 

Teraz problemem jest to, że foaf: członek okazuje się być „null”, a jeśli usunąć te relacje Projekty Projekt dostać osadzony w przypadkach osób.

Odpowiedz

4

Spróbuj z tej ramce zamiast:

{ 
    "@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

jego pracy na placu zabaw JSON-LD, ale nie z biblioteki JSON-LD-Java dla jakiegoś powodu. – amiika

+0

Ale i tak dziękuję, myślę, że to powinno również działać z JSONLD-JAVA. – amiika