-
Notifications
You must be signed in to change notification settings - Fork 23
advice on what to do when encountering @protected terms (vcdm/as2) #424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Related to #361 |
Here is an option that is based off of Example 2 from the Activity Streams spec, which looks like this: {
"@context": {
"@vocab": "https://www.w3.org/ns/activitystreams",
"ext": "https://canine-extension.example/terms/",
"@language": "en"
},
"summary": "A note",
"type": "Note",
"content": "My dog has fleas.",
"ext:nose": 0,
"ext:smell": "terrible"
} You can do this: {
"@context": [
"https://www.w3.org/ns/credentials/v2",
{
"@vocab": "https://www.w3.org/ns/activitystreams#",
"icon": {
"@id": "https://www.w3.org/ns/activitystreams#icon",
"@type": "@id",
"@context": {
"mediaType": "https://www.w3.org/ns/activitystreams#mediaType"
}
}
}
],
"type": [
"VerifiableCredential"
],
"credentialSubject": {
"type": [
"Organization"
],
"icon": {
"type": "Link",
"mediaType": "image/png"
}
}
} Playground link: http://tinyurl.com/yvhnf7vr Note that protected terms can only be overridden when a new term definition is provided with a scoped context -- such that the terms being overridden will be scoped to that new term only. This ensures that consumers can have confidence in the definitions being used based on the structure of the JSON tree. If you wanted to bring in the entire AS context you could also do so using {
"@context": [
"https://www.w3.org/ns/credentials/v2",
{
"@import": "https://www.w3.org/ns/activitystreams",
"mediaType": {
"@id": "https://schema.org/encodingFormat"
},
"icon": {
"@id": "https://www.w3.org/ns/activitystreams#icon",
"@type": "@id",
"@context": {
"mediaType": "https://www.w3.org/ns/activitystreams#mediaType"
}
}
}
],
"type": [
"VerifiableCredential"
],
"credentialSubject": {
"type": [
"Organization"
],
"icon": {
"type": "Link",
"mediaType": "image/png"
}
}
} This approach does an "inline edit" of the AS v2 context via the So there should be a few options here to cause the output to behave properly. Ideally, I think, someone would construct a more modern activity streams context that uses scoped contexts to isolate definitions for usage with other documents types such as VCs. Alternatively, |
@dlongley Thank you, Dave. This looks extremely helpful. I did see in spec text that there may be an affordance for this, but couldn't figure it out in the playground. Sounds like maybe I didn't do the right incantation. Will try it out and get back to you here. tysm! |
Another possible path is to define a property with a scoped context and use that in {
"@context": [
"https://www.w3.org/ns/credentials/v2",
{
"BIKESHED": {
"@id": "https://www.w3.org/ns/activitystreams#credential",
"@type": "@id",
"@context": "https://www.w3.org/ns/activitystreams"
}
}
],
"type": [
"VerifiableCredential"
],
"credentialSubject": {
"BIKESHED": {
"type": [
"Organization"
],
"name": "imaorg",
"icon": {
"type": "Link",
"mediaType": "image/png"
}
}
}
} Pros:
Cons:
|
I have the advice I was originally looking for now. tysm all |
Uh oh!
There was an error while loading. Please reload this page.
Take this example JSON-LD.
it appears to be erroneous do to the
mediaType
property being protected in the outer context, and trying to be redefined in the inner contextThe outer context from
"https://www.w3.org/ns/credentials/v2"
defines amediaType
term as@protected
and with a different IRI as the context inside the credentialSubject which is ActivityStreams2.If possible, I'd love for the JSON serialization of the credentialSubject.icon.mediaType to map to
https://www.w3.org/ns/activitystreams#mediaType
but still use the JSON keymediaType
.This is the first time I've encountered
@protected
terms, so I'm trying to grok what my options are.After tinkering around a bit, I think it might not be possible to do what I want.
(so, for now, when I try to make this JSON-LD, I compact the credentialSubject with a context like
{ "as": "https://www.w3.org/ns/activitystreams#" }
, but then of course I losecredentialSubject.icon.mediaType
and getcredentialSubject.icon["as:mediaType"]
.I also tried to insert a
null
in thecredentialSubject["@context"]
array, but I think that isn't allowed at least by jsonld.js (which I assume is pretty faithful to the spec).The text was updated successfully, but these errors were encountered: