Reputation: 325
I'm learning how to use JSON-LD frames using Node jsonld.js, and I'm wondering why some properties are labeled as IRI whereas others are labeled as terms, and I can't see no obvious reason for that difference.
Here's the sample.
For example, in that sample, the name
property is labeled as expected, whereas in other cases it's labeled as http://www.schema.org/name
, same with url
and http://www.schema.org/url
; and I can't figure out why:
{
"@context": "https://schema.org/docs/jsonldcontext.json",
"@graph": [
{
"id": "_:b0",
"type": "MusicRecording",
"byArtist": {
"id": "_:b1",
"type": "http://www.schema.org/MusicGroup",
"http://www.schema.org/name": "Snoop Dogg",
"http://www.schema.org/sameAs": "/Snoop-Dogg/"
},
"name": "Paper'd Up",
"schema:sameAs": "/Snoop-Dogg/Paper%27d-Up/",
"url": "../Snoop-Dogg/Paper%27d-Up/",
"http://www.schema.org/duration": "PT3M55S",
"http://www.schema.org/image": "/static/track_images_200/lr1734_2009720_1372375126.jpg",
"http://www.schema.org/inAlbum": {
"id": "_:b2",
"type": "http://www.schema.org/MusicAlbum",
"http://www.schema.org/albumRelease": {
"id": "_:b4",
"type": "http://www.schema.org/MusicRelease",
"http://www.schema.org/datePublished": "2001",
"http://www.schema.org/recordLabel": "Priority"
},
"http://www.schema.org/name": "Paid the Cost to Be the Bo$$"
},
"http://www.schema.org/producer": {
"id": "_:b3",
"type": "http://www.schema.org/Person",
"http://www.schema.org/name": "Fredwreck",
"http://www.schema.org/sameAs": "/Fredwreck/",
"http://www.schema.org/url": {
"id": "../Fredwreck/"
}
},
"http://www.schema.org/thumbnailUrl": {
"id": "../static/track_images_100/mr1734_2009720_1372375126.jpg"
}
}
]
}
How to retrieve the tree with properties named as type instead of IRI (using jsonld.js)?
Upvotes: 1
Views: 359
Reputation: 1906
It's necessary that the term match the IRI you use for the property. For example, schema.org defines name
as http://schema.org/name
. In your example, you have http://www.schema.org/name
.
There are also several places where values which should be IRIs (URLs) are treated as text, for this you want to use something like "http://schema.org/image": {"@id": "/static/track_images_200/lr1734_2009720_1372375126.jpg"}
Part of term selection looks to be sure that a value matches the appropriate @type
definition within the context. For example, image
is set to {"@type": "@id"}
, so it will only match things that look like that.
Here's an updated example on the playground.
Upvotes: 2