Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Fediverse
  3. Fedi
  4. I have deeply mixed feelings about #ActivityPub's adoption of JSON-LD, as someone who's spent way too long dealing with it while building #Fedify.

I have deeply mixed feelings about #ActivityPub's adoption of JSON-LD, as someone who's spent way too long dealing with it while building #Fedify.

Scheduled Pinned Locked Moved Fedi
fedifyjsonldfedidevactivitypub
115 Posts 26 Posters 469 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • trwnh@mastodon.socialT trwnh@mastodon.social

    @raphael @silverpill @hongminhee @mariusor most often the trouble i see is with ignoring the fact that everyone is using the same terms with different meanings, and pretending that we all agree when we actually do not.

    the second most common issue i see is with the complete lack of any guarantees beyond "this thing is probably an activity" (which even that small bit is often discarded!)

    json-ld is so far down the list of pain points, and the pain comes from ignoring it or misusing it.

    trwnh@mastodon.socialT This user is from outside of this forum
    trwnh@mastodon.socialT This user is from outside of this forum
    trwnh@mastodon.social
    wrote last edited by
    #99

    @raphael @silverpill @hongminhee @mariusor example: if you took lemmy's use of as:Group you might assume that every as:Group is a lemmy-style "community" and that it always produces 1b12-style Announce activities, and that "Announce" means how they use it and not its actual definition.

    now if lemmy had used their own vocabulary, it might be easier to understand that "this is a lemmy-style community".

    the activity processing model shouldn't care what lemmy properties are used.

    trwnh@mastodon.socialT 1 Reply Last reply
    0
    • trwnh@mastodon.socialT trwnh@mastodon.social

      @raphael @silverpill @hongminhee @mariusor example: if you took lemmy's use of as:Group you might assume that every as:Group is a lemmy-style "community" and that it always produces 1b12-style Announce activities, and that "Announce" means how they use it and not its actual definition.

      now if lemmy had used their own vocabulary, it might be easier to understand that "this is a lemmy-style community".

      the activity processing model shouldn't care what lemmy properties are used.

      trwnh@mastodon.socialT This user is from outside of this forum
      trwnh@mastodon.socialT This user is from outside of this forum
      trwnh@mastodon.social
      wrote last edited by
      #100

      @raphael @silverpill @hongminhee @mariusor what is far more powerful is drawing *equivalences* between values. you might say every lemmy:Community is also always as:Group, but not every as:Group is always a lemmy:Community. in this case we are basically saying lemmy:Community is rdfs:subClassOf as:Group.

      separately we might say every as:Group is also a vcard:Group, and vice versa -- that might make them owl:equivalentClass, but that doesn't mean the "activity model" and "vcard model" are equal!

      1 Reply Last reply
      0
      • trwnh@mastodon.socialT trwnh@mastodon.social

        @hongminhee what i have found necessary (sadly) is to sometimes ignore what @\context a software produces and simply inject a corrected @\context describing what they *actually* meant instead of what they said they meant. x_x

        Link Preview Image
        the "incorrect" mastodon context in use right now (or equivalent), which can be swapped out for the "correct" mastodon context to be more compatible with generic json-ld (and more semantically correct)

        the "incorrect" mastodon context in use right now (or equivalent), which can be swapped out for the "correct" mastodon context to be more compatible with generic json-ld (and more semantically correct) - mastodon-context-correct.jsonld

        favicon

        Gist (gist.github.com)

        it would be an Exercise to sit down and map out the actual contexts of softwares like mastodon 4.5, mastodon 4.4, misskey 2025.12, akkoma 3.10.2, and so on...

        for all else, there's shacl i guess, if you want to beat things into the correct shapes.

        julian@activitypub.spaceJ This user is from outside of this forum
        julian@activitypub.spaceJ This user is from outside of this forum
        julian@activitypub.space
        wrote last edited by
        #101

        @trwnh@mastodon.social it's not an exercise, not anymore, with the Fediverse Observatory!

        1 Reply Last reply
        1
        0
        • R relay@relay.an.exchange shared this topic
        • trwnh@mastodon.socialT trwnh@mastodon.social

          @kopper @hongminhee

          generally agreed except

          > you have to map the expanded representation to your internal structure which will likely be modeled after the compacted one

          this is compaction but manual instead of using a jsonld processor to do it. maybe the more precise argument is "don't bother with auto/native compaction"?

          with that said: you also lose out on flattening and framing, which are pretty cool features for transforming the serialization. if you don't care about those, ok fine

          kopper@not-brain.d.on-t.workK This user is from outside of this forum
          kopper@not-brain.d.on-t.workK This user is from outside of this forum
          kopper@not-brain.d.on-t.work
          wrote last edited by
          #102
          @trwnh @hongminhee i'm not entirely sure on what you mean (it's about 3am here) but compaction isnt that cheap.

          flattening and especially framing are the most expensive, and expansion is the cheapest especially since all the other algorithms depend on it (though if you do expand manually before it'll take a fast path out)

          my argument here is that, if you know the structure you're serializing to (i.e. if you're a contemporary AP implementation that isn't doing anything too fancy), you can directly serialize in compacted form and skip constructing a tree of JSON objects in your library and running the compaction algorithm over it. depending on how clever you(r libraries) get you may be able to directly write the JSON string directly, even.

          from some brief profiling i've done this does show up as a hot code path in iceshrimp.net, one of my goals with Eventually replacing dotNetRdf with my own impl mentioned above is to, given i'm gonna have to mess with serialization anyhow, remove the JSON-LD bits there and serialize directly to compacted form which should help with large boosts and other bursts
          1 Reply Last reply
          1
          0
          • kopper@not-brain.d.on-t.workK kopper@not-brain.d.on-t.work
            @hongminhee from the point of view of someone who is "maintaining" a JSON-LD processing fedi software and has implemented their own JSON-LD processing library (which is, to my knowledge, the fastest in it's programming language), JSON-LD is pure overhead. there is nothing it allows for that can't be done with

            1. making fields which take multiple values explicit
            2. always using namespaces and letting HTTP compression take care of minimizing the transfer

            without JSON-LD, fedi software could use zero-ish-copy deserialization for a majority of their objects (when strings aren't escaped) through tools like serde_json and Cow<str>, or
            System.Text.Json.JsonDocument. JSON-LD processing effectively mandates a JSON node DOM (in the algorithms standardized, you may be able to get rid of it with Clever Programming)

            additionally, due to JSON-LD 1.1 features like @type:@json, you can not even fetch contexts ahead of time of running JSON DOM transformations, meaning all JSON-LD code has to be async (in the languages which has the concept), potentially losing out on significant optimizations that can't be done in coroutines due to various reasons (e.g. C# async methods can't have ref structs, Rust async functions usually require thread safety due to tokio's prevalence, even if they're ran in a single-threaded runtime)

            this is
            after context processing introducing network dependency to the deserialization of data, wasting time and data on non-server cases (e.g. activitypub C2S). sure you can cache individual contexts, but then the context can change underneath you, desynchronizing your cached context and, in the worst case, opening you up to security vulnerabilities

            json-ld is not my favorite part of this protocol
            cwebber@social.coopC This user is from outside of this forum
            cwebber@social.coopC This user is from outside of this forum
            cwebber@social.coop
            wrote last edited by
            #103

            @kopper @hongminhee As the person probably most responsible for making sure json-ld stayed in the spec (two reasons: because it was the only extensibility answer we had, and because we were trying hard to retain interoperability with the linked data people, which ultimately did not matter), I agree with you. I do ultimately regret not having a simpler solution than json-ld, especially because it greatly hurt our ability to sign messages, which has considerable effect on the ecosystem.

            Mea culpa 😕

            I do think it's fixable. I'd be interested in joining a conversation about how to fix it.

            evan@cosocial.caE 1 Reply Last reply
            0
            • cwebber@social.coopC cwebber@social.coop

              @kopper @hongminhee As the person probably most responsible for making sure json-ld stayed in the spec (two reasons: because it was the only extensibility answer we had, and because we were trying hard to retain interoperability with the linked data people, which ultimately did not matter), I agree with you. I do ultimately regret not having a simpler solution than json-ld, especially because it greatly hurt our ability to sign messages, which has considerable effect on the ecosystem.

              Mea culpa 😕

              I do think it's fixable. I'd be interested in joining a conversation about how to fix it.

              evan@cosocial.caE This user is from outside of this forum
              evan@cosocial.caE This user is from outside of this forum
              evan@cosocial.ca
              wrote last edited by
              #104

              @cwebber @kopper @hongminhee

              I don't remember it that way.

              We started the WG off with AS2 being based on JSON-LD, and I don't think we ever considered removing it.

              I don't think it was a decision you made on your own. I'm not sure how you would, since you edited AP and not AS2 Core or Vocabulary.

              evan@cosocial.caE 1 Reply Last reply
              0
              • evan@cosocial.caE evan@cosocial.ca

                @cwebber @kopper @hongminhee

                I don't remember it that way.

                We started the WG off with AS2 being based on JSON-LD, and I don't think we ever considered removing it.

                I don't think it was a decision you made on your own. I'm not sure how you would, since you edited AP and not AS2 Core or Vocabulary.

                evan@cosocial.caE This user is from outside of this forum
                evan@cosocial.caE This user is from outside of this forum
                evan@cosocial.ca
                wrote last edited by
                #105

                @cwebber @kopper @hongminhee

                I would be strongly opposed to any effort to remove JSON-LD from AS2. We use it for a lot of extensions. Every AP server uses the Security vocabulary for public keys.

                evan@cosocial.caE 1 Reply Last reply
                0
                • evan@cosocial.caE evan@cosocial.ca

                  @cwebber @kopper @hongminhee

                  I would be strongly opposed to any effort to remove JSON-LD from AS2. We use it for a lot of extensions. Every AP server uses the Security vocabulary for public keys.

                  evan@cosocial.caE This user is from outside of this forum
                  evan@cosocial.caE This user is from outside of this forum
                  evan@cosocial.ca
                  wrote last edited by
                  #106

                  @cwebber @kopper @hongminhee It would be a huge backwards-incompatible change for almost zero benefit. People would still make mistakes in their ActivityPub implementations (sorry, Minhee, but that's life on an open network). We'd need to adopt another mechanism for defining extensions, and guess what? People are going to make mistakes with that, too.

                  evan@cosocial.caE 1 Reply Last reply
                  0
                  • evan@cosocial.caE evan@cosocial.ca

                    @cwebber @kopper @hongminhee It would be a huge backwards-incompatible change for almost zero benefit. People would still make mistakes in their ActivityPub implementations (sorry, Minhee, but that's life on an open network). We'd need to adopt another mechanism for defining extensions, and guess what? People are going to make mistakes with that, too.

                    evan@cosocial.caE This user is from outside of this forum
                    evan@cosocial.caE This user is from outside of this forum
                    evan@cosocial.ca
                    wrote last edited by
                    #107

                    @cwebber @kopper @hongminhee The biggest downside to JSON-LD, it seems, is that it lets most developers treat AS2 as if it's plain old JSON. That was by design. People sometimes mess it up, but most JSON-LD parsers are pretty tolerant.

                    gugurumbe@mastouille.frG 1 Reply Last reply
                    0
                    • evan@cosocial.caE evan@cosocial.ca

                      @cwebber @kopper @hongminhee The biggest downside to JSON-LD, it seems, is that it lets most developers treat AS2 as if it's plain old JSON. That was by design. People sometimes mess it up, but most JSON-LD parsers are pretty tolerant.

                      gugurumbe@mastouille.frG This user is from outside of this forum
                      gugurumbe@mastouille.frG This user is from outside of this forum
                      gugurumbe@mastouille.fr
                      wrote last edited by
                      #108

                      @evan @cwebber @kopper @hongminhee Couldn’t we agree to standardize on expanded json-ld? We would not need any json-ld processor, we would not need to fetch or cache any context. There would be no way to shadow properties.

                      evan@cosocial.caE 1 Reply Last reply
                      0
                      • gugurumbe@mastouille.frG gugurumbe@mastouille.fr

                        @evan @cwebber @kopper @hongminhee Couldn’t we agree to standardize on expanded json-ld? We would not need any json-ld processor, we would not need to fetch or cache any context. There would be no way to shadow properties.

                        evan@cosocial.caE This user is from outside of this forum
                        evan@cosocial.caE This user is from outside of this forum
                        evan@cosocial.ca
                        wrote last edited by
                        #109

                        @gugurumbe @cwebber @kopper @hongminhee AS2 requires compacted JSON-LD.

                        trwnh@mastodon.socialT 1 Reply Last reply
                        0
                        • evan@cosocial.caE evan@cosocial.ca

                          @gugurumbe @cwebber @kopper @hongminhee AS2 requires compacted JSON-LD.

                          trwnh@mastodon.socialT This user is from outside of this forum
                          trwnh@mastodon.socialT This user is from outside of this forum
                          trwnh@mastodon.social
                          wrote last edited by
                          #110

                          @evan @gugurumbe @cwebber @kopper @hongminhee only for terms defined in AS2, though?

                          if the activitystreams context is missing in an application/activity+json document, then you MUST assume/inject it. this means you can't redefine "actor" to mean "actor in a movie".

                          otherwise, you don't have to augment the context with anything else. "https://w3id.org/security#publicKey" is a valid property name. the proposal is to not augment the normative context where possible. no parsing context if there is no context

                          evan@cosocial.caE 1 Reply Last reply
                          0
                          • trwnh@mastodon.socialT trwnh@mastodon.social

                            @evan @gugurumbe @cwebber @kopper @hongminhee only for terms defined in AS2, though?

                            if the activitystreams context is missing in an application/activity+json document, then you MUST assume/inject it. this means you can't redefine "actor" to mean "actor in a movie".

                            otherwise, you don't have to augment the context with anything else. "https://w3id.org/security#publicKey" is a valid property name. the proposal is to not augment the normative context where possible. no parsing context if there is no context

                            evan@cosocial.caE This user is from outside of this forum
                            evan@cosocial.caE This user is from outside of this forum
                            evan@cosocial.ca
                            wrote last edited by
                            #111

                            @trwnh i was replying to a post that wanted all expanded terms.

                            @gugurumbe @cwebber @kopper @hongminhee

                            gugurumbe@mastouille.frG 1 Reply Last reply
                            0
                            • evan@cosocial.caE evan@cosocial.ca

                              @trwnh i was replying to a post that wanted all expanded terms.

                              @gugurumbe @cwebber @kopper @hongminhee

                              gugurumbe@mastouille.frG This user is from outside of this forum
                              gugurumbe@mastouille.frG This user is from outside of this forum
                              gugurumbe@mastouille.fr
                              wrote last edited by
                              #112

                              @evan @trwnh @cwebber @kopper @hongminhee I think it would be great to have everything expanded besides the required as2 context.
                              The results of the compaction algorithm would change if new things migrate into schema.org, so technically a document could become invalid or break without being modified, but this would be a lot better otherwise I guess.

                              trwnh@mastodon.socialT 1 Reply Last reply
                              0
                              • gugurumbe@mastouille.frG gugurumbe@mastouille.fr

                                @evan @trwnh @cwebber @kopper @hongminhee I think it would be great to have everything expanded besides the required as2 context.
                                The results of the compaction algorithm would change if new things migrate into schema.org, so technically a document could become invalid or break without being modified, but this would be a lot better otherwise I guess.

                                trwnh@mastodon.socialT This user is from outside of this forum
                                trwnh@mastodon.socialT This user is from outside of this forum
                                trwnh@mastodon.social
                                wrote last edited by
                                #113

                                @gugurumbe @evan @cwebber @kopper @hongminhee yup, using full IRIs also has the advantage that ld-unaware processors only need to recognize 1 form instead of infinitely many.

                                the thing is, we have semantics imported from the content type (activity+json) which can also change. which is why i think versioning the context document is also important -- it freezes the semantics at the time of publishing, like pinning your dependencies.

                                without that, we might well have a simpler profile...

                                gugurumbe@mastouille.frG 1 Reply Last reply
                                0
                                • trwnh@mastodon.socialT trwnh@mastodon.social

                                  @gugurumbe @evan @cwebber @kopper @hongminhee yup, using full IRIs also has the advantage that ld-unaware processors only need to recognize 1 form instead of infinitely many.

                                  the thing is, we have semantics imported from the content type (activity+json) which can also change. which is why i think versioning the context document is also important -- it freezes the semantics at the time of publishing, like pinning your dependencies.

                                  without that, we might well have a simpler profile...

                                  gugurumbe@mastouille.frG This user is from outside of this forum
                                  gugurumbe@mastouille.frG This user is from outside of this forum
                                  gugurumbe@mastouille.fr
                                  wrote last edited by
                                  #114

                                  @trwnh as a paranoid person, I sometimes wonder what would happen if schema.org received a court order to partially censor its schema in certain regions of the world. Or inject a backdoor key. If it prevents people from sending memes across the geofence, it’s bad.

                                  1 Reply Last reply
                                  1
                                  0
                                  Reply
                                  • Reply as topic
                                  Log in to reply
                                  • Oldest to Newest
                                  • Newest to Oldest
                                  • Most Votes


                                  • Login

                                  • Login or register to search.
                                  • First post
                                    Last post
                                  0
                                  • Categories
                                  • Recent
                                  • Tags
                                  • Popular
                                  • World
                                  • Users
                                  • Groups