Created
December 10, 2013 00:43
-
-
Save jeffhandley/7883875 to your computer and use it in GitHub Desktop.
Named objects in a graph
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// What Example 46 shows here: http://json-ld.org/spec/latest/json-ld | |
"@graph" : [ | |
{ | |
"@id": "#homer", | |
"http://example.com/vocab#name": "Homer" | |
}, | |
{ | |
"@id": "#bart", | |
"http://example.com/vocab#name": "Bart", | |
"http://example.com/vocab#parent": { "@id": "#homer" } | |
}, | |
{ | |
"@id": "#lisa", | |
"http://example.com/vocab#name": "Lisa", | |
"http://example.com/vocab#parent": { "@id": "#homer" } | |
} | |
] | |
// What we want | |
"@graph" : { | |
"#homer" : { | |
"http://example.com/vocab#name": "Homer" | |
}, | |
"#bart" : { | |
"http://example.com/vocab#name": "Bart", | |
"http://example.com/vocab#parent": { "@id": "#homer" } | |
}, | |
"#lisa" : { | |
"http://example.com/vocab#name": "Lisa", | |
"http://example.com/vocab#parent": { "@id": "#homer" } | |
} | |
} |
We were looking at the indexing feature, so we'll look into that more; thanks!
And good to know about @graph being unnecessary here.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can achieve something like that through JSON-LD's Data Indexing feature: http://www.w3.org/TR/json-ld/#data-indexing
Note, you will lose the @id if you don't "repeat" it in the object... also, you probably don't need @graph there.