In ActivityPub, these are all equivalent:
-
@reiver That's... kinda shite.
-
@reiver That's assuming "Banana" is a term defined in the JSON-LD context. Even then, the expanded "Banana" term (e.g., "https://server.example/fruits#Banana" is also valid and equivalent.
-
@reiver That's assuming "Banana" is a term defined in the JSON-LD context. Even then, the expanded "Banana" term (e.g., "https://server.example/fruits#Banana" is also valid and equivalent.
Yes, you are correct, all those are equivalent, too.
Plus any CURIE form (ex: abc:Banana).
I couldn't fit all those in the 500 character limit.
-
@reiver That's assuming "Banana" is a term defined in the JSON-LD context. Even then, the expanded "Banana" term (e.g., "https://server.example/fruits#Banana" is also valid and equivalent.
@steve @reiver See https://github.com/w3c/json-ld-syntax/issues/446 for a related issue. JSON-LD @\type IRIs get expanded against a @\vocab prefix, or if one is not present then they get expanded against the @\base, and if *that* can't be determined then they are actually not expanded.
However, you don't have to worry about cases like "@type":{"@id":"Banana"} because those are not valid. Per https://www.w3.org/TR/json-ld11/#specifying-the-type you only have to worry about strings and arrays of strings.
Also AS2 compacts @\type to type.
-
@steve @reiver See https://github.com/w3c/json-ld-syntax/issues/446 for a related issue. JSON-LD @\type IRIs get expanded against a @\vocab prefix, or if one is not present then they get expanded against the @\base, and if *that* can't be determined then they are actually not expanded.
However, you don't have to worry about cases like "@type":{"@id":"Banana"} because those are not valid. Per https://www.w3.org/TR/json-ld11/#specifying-the-type you only have to worry about strings and arrays of strings.
Also AS2 compacts @\type to type.
-
@reiver That's... kinda shite.
@OliviaVespera @reiver It's also not correct; only the first 2 cases are valid/compliant. (If ActivityPub didn't define "type" to mean @\type, then it would be only the 7th and 8th cases in that list.)
-
@trwnh @reiver The classic example of this issue is a property like `attributedTo` or its subproperty `actor` (just two of many examples). The range is Object|Link. That means the property value could be URI, an Object, a Link or an array (set) of any combination of URIs, Objects or Links where the URI could be compacted, expanded or a CURIE.
-
@trwnh @reiver The classic example of this issue is a property like `attributedTo` or its subproperty `actor` (just two of many examples). The range is Object|Link. That means the property value could be URI, an Object, a Link or an array (set) of any combination of URIs, Objects or Links where the URI could be compacted, expanded or a CURIE.
@steve @reiver Yup. Makes me wish we used an actual normal/canonical form that was more constrained. Even in the AS2 context I've oft thought @\type: @\id could be a mistake since {id: foo} is usually preferable; also, any non-functional property really ought to be @\container: @\set. those would be backwards-incompatible changes, though. and even if someone defined a simpler easier-to-understand profile, what's the point if people don't use it?
-
@OliviaVespera @reiver It's also not correct; only the first 2 cases are valid/compliant. (If ActivityPub didn't define "type" to mean @\type, then it would be only the 7th and 8th cases in that list.)
Why do you feel that the 7th & 8th cases are not "valid"?
"@type":"Banana"
"@type":["Banana"]
...
At the following, "type" is set as an alias for "@type":
https://www.w3.org/ns/activitystreams.jsonld
But, AFAICT, in JSON-LD creating an alias (such as "type") does not make the original form (such as "@type") invalid.
Are you claiming the 7th & 8th form are invalid JSON-LD?
Or, are you claiming the 7th & 8th form are valid JSON-LD, but invalid ActivityPub?
Or, something else?
-
Why do you feel that the 7th & 8th cases are not "valid"?
"@type":"Banana"
"@type":["Banana"]
...
At the following, "type" is set as an alias for "@type":
https://www.w3.org/ns/activitystreams.jsonld
But, AFAICT, in JSON-LD creating an alias (such as "type") does not make the original form (such as "@type") invalid.
Are you claiming the 7th & 8th form are invalid JSON-LD?
Or, are you claiming the 7th & 8th form are valid JSON-LD, but invalid ActivityPub?
Or, something else?
@reiver @OliviaVespera valid JSON-LD but noncompliant AS2, due to ignoring the term definition for "type".
-
@reiver@mastodon.social That's not true. Most of those are not correct AS2. Only '"type": "Banana"' is correct.
Activity Streams says, The serialized JSON form of an Activity Streams 2.0 document MUST be consistent with what would be produced by the standard JSON-LD 1.0 Processing Algorithms and API [JSON-LD-API] Compaction Algorithm using, at least, the normative JSON-LD @context definition provided here.
So, assuming that you've defined some Banana extension, your full code might look like this:
{ "@context": [ "https://www.w3.org/ns/activitystreams", { "ext": "https://banana.example/", "Banana": { "@type": "@id", "@id": "ext:Banana" } } ], "type": "Banana" }If you use a JSON-LD library for parsing your input, all the funky variants you're sharing get canonicalized into one easy-to-use one. And if you use it for formatting your output, you'll always produce nice, clean AS2.
-
Oh, and if you're using an AS2 type, you don't have to worry about the extra context URL, obvs:
{ "@context": "https://www.w3.org/ns/activitystreams", "type": "Person" }
Ciao! Sembra che tu sia interessato a questa conversazione, ma non hai ancora un account.
Stanco di dover scorrere gli stessi post a ogni visita? Quando registri un account, tornerai sempre esattamente dove eri rimasto e potrai scegliere di essere avvisato delle nuove risposte (tramite email o notifica push). Potrai anche salvare segnalibri e votare i post per mostrare il tuo apprezzamento agli altri membri della comunità.
Con il tuo contributo, questo post potrebbe essere ancora migliore 💗
Registrati Accedi