Giter VIP home page Giter VIP logo

Comments (6)

naturzukunft avatar naturzukunft commented on August 19, 2024

The AP community discussions are in the socialhub

https://socialhub.activitypub.rocks/t/is-json-ld-compatibe-to-json-ld-and-what-does-activitypub-understand-with-json-ld

from titanium-json-ld.

nightpool avatar nightpool commented on August 19, 2024

Note, the rules for ActivityStreams "compatiblity" are very simple, and they're given in AS2 Core section 2.1:

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. Implementations MAY augment the provided @context with additional @context definitions but MUST NOT override or change the normative context. Implementations MAY also use additional properties and values not defined in the JSON-LD @context with the understanding that any such properties will likely be unsupported and ignored by consuming implementations that use the standard JSON-LD algorithms. See the Extensibility section for more information on handling extensions within Activity Streams 2.0 documents.

The demo code that @naturzukunft posted on SocialHub boils down to a single call to .compact() with the https://www.w3.org/ns/activitystreams normative context, which seems correct to me. I'm not sure if this feature request means that there's a problem with that code, or if the idea here is just that titanium-json-ld can make that compact call itself internally?

from titanium-json-ld.

naturzukunft avatar naturzukunft commented on August 19, 2024

The feature request concerns RDF models that contain predicates from multiple namespaces. So not only "https://www.w3.org/ns/activitystreams". Maybe titanum can do that already and I just don't know it. I'll try to provide one or more sample(s) these days.

from titanium-json-ld.

naturzukunft avatar naturzukunft commented on August 19, 2024

My sample in turtle:

@prefix rdfpub: <http://rdf-pub.org#> .
@prefix schema: <http://schema.org/> .
@prefix as: <https://www.w3.org/ns/activitystreams#> .

<http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d> a as:Person;
  rdfpub:inboxSparql <http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/inbox/sparql>;
  rdfpub:outboxSparql <http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/outbox/sparql>;
  schema:identifier "45aef045-ce21-4a8e-a844-64b7bd7df04b";
  schema:version "1"^^<http://www.w3.org/2001/XMLSchema#long>;
  as:Public <http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/asPublic>;
  as:attributedTo "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3drdfPubActorUserName";
  as:inbox <http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/inbox>;
  as:outbox <http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/outbox>;
  as:preferredUsername "max" .

It's a rdf4j model. if i print it out in default rdf4j json-ld, it looks like that:

[ {
  "@graph" : [ {
    "@id" : "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d",
    "@type" : [ "https://www.w3.org/ns/activitystreams#Person" ],
    "http://rdf-pub.org#inboxSparql" : [ {
      "@id" : "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/inbox/sparql"
    } ],
    "http://rdf-pub.org#outboxSparql" : [ {
      "@id" : "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/outbox/sparql"
    } ],
    "http://schema.org/identifier" : [ {
      "@value" : "45aef045-ce21-4a8e-a844-64b7bd7df04b"
    } ],
    "http://schema.org/version" : [ {
      "@type" : "http://www.w3.org/2001/XMLSchema#long",
      "@value" : "1"
    } ],
    "https://www.w3.org/ns/activitystreams#Public" : [ {
      "@id" : "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/asPublic"
    } ],
    "https://www.w3.org/ns/activitystreams#attributedTo" : [ {
      "@value" : "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3drdfPubActorUserName"
    } ],
    "https://www.w3.org/ns/activitystreams#inbox" : [ {
      "@id" : "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/inbox"
    } ],
    "https://www.w3.org/ns/activitystreams#outbox" : [ {
      "@id" : "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/outbox"
    } ],
    "https://www.w3.org/ns/activitystreams#preferredUsername" : [ {
      "@value" : "max"
    } ]
  } ],
  "@id" : "https://www.w3.org/ns/activitystreams#Public"
} ]

After doing a 'compact' with titanum (maybe my 'jsonObjectToString' is wrong?!)

public void test()
{
    ...
    Document document = JsonDocument.of(new StringReader(jsonLdRdf4jDefault));
    JsonObject jObj =JsonLd.compact(document, "https://www.w3.org/ns/activitystreams").get();
    System.out.println("jObj: " + jsonObjectToString(jObj));
}

private static String jsonObjectToString(JsonObject json) throws IOException	{
    Map<String,Boolean> config = new HashMap<>();
    config.put(JsonGenerator.PRETTY_PRINTING, true);
 
    JsonWriterFactory writerFactory = Json.createWriterFactory(config);
    try (Writer stringWriter = new StringWriter(); 
         JsonWriter jsonWriter = writerFactory.createWriter(stringWriter)) {
        jsonWriter.write(json);
        return stringWriter.toString();
    }
}

The compact method does allow one 'contextLocation', but i would also like to use https://schema.org/docs/jsonldcontext.json.

it looks like that:

{
    "@graph": [
        {
            "id": "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d",
            "type": "Person",
            "http://rdf-pub.org#inboxSparql": {
                "id": "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/inbox/sparql"
            },
            "http://rdf-pub.org#outboxSparql": {
                "id": "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/outbox/sparql"
            },
            "http://schema.org/identifier": "45aef045-ce21-4a8e-a844-64b7bd7df04b",
            "http://schema.org/version": {
                "type": "xsd:long",
                "@value": "1"
            },
            "Public": "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/asPublic",
            "as:attributedTo": "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3drdfPubActorUserName",
            "as:inbox": {
                "id": "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/inbox"
            },
            "outbox": "http://localhost:8081/actor/1813bdc1-152c-4c27-92a6-6cdfe401ef3d/outbox",
            "preferredUsername": "max"
        }
    ],
    "id": "as:Public",
    "@context": {
        "@vocab": "_:",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "as": "https://www.w3.org/ns/activitystreams#",
        "ldp": "http://www.w3.org/ns/ldp#",
        "vcard": "http://www.w3.org/2006/vcard/ns#",
        "id": "@id",
        "type": "@type",
        "Accept": "as:Accept",
        "Activity": "as:Activity",
        "IntransitiveActivity": "as:IntransitiveActivity",
        "Add": "as:Add",
        "Announce": "as:Announce",
        "Application": "as:Application",
        "Arrive": "as:Arrive",
        "Article": "as:Article",
        "Audio": "as:Audio",
        "Block": "as:Block",
        "Collection": "as:Collection",
        "CollectionPage": "as:CollectionPage",
        "Relationship": "as:Relationship",
        "Create": "as:Create",
        "Delete": "as:Delete",
        "Dislike": "as:Dislike",
        "Document": "as:Document",
        "Event": "as:Event",
        "Follow": "as:Follow",
        "Flag": "as:Flag",
        "Group": "as:Group",
        "Ignore": "as:Ignore",
        "Image": "as:Image",
        "Invite": "as:Invite",
        "Join": "as:Join",
        "Leave": "as:Leave",
        "Like": "as:Like",
        "Link": "as:Link",
        "Mention": "as:Mention",
        "Note": "as:Note",
        "Object": "as:Object",
        "Offer": "as:Offer",
        "OrderedCollection": "as:OrderedCollection",
        "OrderedCollectionPage": "as:OrderedCollectionPage",
        "Organization": "as:Organization",
        "Page": "as:Page",
        "Person": "as:Person",
        "Place": "as:Place",
        "Profile": "as:Profile",
        "Question": "as:Question",
        "Reject": "as:Reject",
        "Remove": "as:Remove",
        "Service": "as:Service",
        "TentativeAccept": "as:TentativeAccept",
        "TentativeReject": "as:TentativeReject",
        "Tombstone": "as:Tombstone",
        "Undo": "as:Undo",
        "Update": "as:Update",
        "Video": "as:Video",
        "View": "as:View",
        "Listen": "as:Listen",
        "Read": "as:Read",
        "Move": "as:Move",
        "Travel": "as:Travel",
        "IsFollowing": "as:IsFollowing",
        "IsFollowedBy": "as:IsFollowedBy",
        "IsContact": "as:IsContact",
        "IsMember": "as:IsMember",
        "subject": {
            "@id": "as:subject",
            "@type": "@id"
        },
        "relationship": {
            "@id": "as:relationship",
            "@type": "@id"
        },
        "actor": {
            "@id": "as:actor",
            "@type": "@id"
        },
        "attributedTo": {
            "@id": "as:attributedTo",
            "@type": "@id"
        },
        "attachment": {
            "@id": "as:attachment",
            "@type": "@id"
        },
        "bcc": {
            "@id": "as:bcc",
            "@type": "@id"
        },
        "bto": {
            "@id": "as:bto",
            "@type": "@id"
        },
        "cc": {
            "@id": "as:cc",
            "@type": "@id"
        },
        "context": {
            "@id": "as:context",
            "@type": "@id"
        },
        "current": {
            "@id": "as:current",
            "@type": "@id"
        },
        "first": {
            "@id": "as:first",
            "@type": "@id"
        },
        "generator": {
            "@id": "as:generator",
            "@type": "@id"
        },
        "icon": {
            "@id": "as:icon",
            "@type": "@id"
        },
        "image": {
            "@id": "as:image",
            "@type": "@id"
        },
        "inReplyTo": {
            "@id": "as:inReplyTo",
            "@type": "@id"
        },
        "items": {
            "@id": "as:items",
            "@type": "@id"
        },
        "instrument": {
            "@id": "as:instrument",
            "@type": "@id"
        },
        "orderedItems": {
            "@id": "as:items",
            "@type": "@id",
            "@container": "@list"
        },
        "last": {
            "@id": "as:last",
            "@type": "@id"
        },
        "location": {
            "@id": "as:location",
            "@type": "@id"
        },
        "next": {
            "@id": "as:next",
            "@type": "@id"
        },
        "object": {
            "@id": "as:object",
            "@type": "@id"
        },
        "oneOf": {
            "@id": "as:oneOf",
            "@type": "@id"
        },
        "anyOf": {
            "@id": "as:anyOf",
            "@type": "@id"
        },
        "closed": {
            "@id": "as:closed",
            "@type": "xsd:dateTime"
        },
        "origin": {
            "@id": "as:origin",
            "@type": "@id"
        },
        "accuracy": {
            "@id": "as:accuracy",
            "@type": "xsd:float"
        },
        "prev": {
            "@id": "as:prev",
            "@type": "@id"
        },
        "preview": {
            "@id": "as:preview",
            "@type": "@id"
        },
        "replies": {
            "@id": "as:replies",
            "@type": "@id"
        },
        "result": {
            "@id": "as:result",
            "@type": "@id"
        },
        "audience": {
            "@id": "as:audience",
            "@type": "@id"
        },
        "partOf": {
            "@id": "as:partOf",
            "@type": "@id"
        },
        "tag": {
            "@id": "as:tag",
            "@type": "@id"
        },
        "target": {
            "@id": "as:target",
            "@type": "@id"
        },
        "to": {
            "@id": "as:to",
            "@type": "@id"
        },
        "url": {
            "@id": "as:url",
            "@type": "@id"
        },
        "altitude": {
            "@id": "as:altitude",
            "@type": "xsd:float"
        },
        "content": "as:content",
        "contentMap": {
            "@id": "as:content",
            "@container": "@language"
        },
        "name": "as:name",
        "nameMap": {
            "@id": "as:name",
            "@container": "@language"
        },
        "duration": {
            "@id": "as:duration",
            "@type": "xsd:duration"
        },
        "endTime": {
            "@id": "as:endTime",
            "@type": "xsd:dateTime"
        },
        "height": {
            "@id": "as:height",
            "@type": "xsd:nonNegativeInteger"
        },
        "href": {
            "@id": "as:href",
            "@type": "@id"
        },
        "hreflang": "as:hreflang",
        "latitude": {
            "@id": "as:latitude",
            "@type": "xsd:float"
        },
        "longitude": {
            "@id": "as:longitude",
            "@type": "xsd:float"
        },
        "mediaType": "as:mediaType",
        "published": {
            "@id": "as:published",
            "@type": "xsd:dateTime"
        },
        "radius": {
            "@id": "as:radius",
            "@type": "xsd:float"
        },
        "rel": "as:rel",
        "startIndex": {
            "@id": "as:startIndex",
            "@type": "xsd:nonNegativeInteger"
        },
        "startTime": {
            "@id": "as:startTime",
            "@type": "xsd:dateTime"
        },
        "summary": "as:summary",
        "summaryMap": {
            "@id": "as:summary",
            "@container": "@language"
        },
        "totalItems": {
            "@id": "as:totalItems",
            "@type": "xsd:nonNegativeInteger"
        },
        "units": "as:units",
        "updated": {
            "@id": "as:updated",
            "@type": "xsd:dateTime"
        },
        "width": {
            "@id": "as:width",
            "@type": "xsd:nonNegativeInteger"
        },
        "describes": {
            "@id": "as:describes",
            "@type": "@id"
        },
        "formerType": {
            "@id": "as:formerType",
            "@type": "@id"
        },
        "deleted": {
            "@id": "as:deleted",
            "@type": "xsd:dateTime"
        },
        "inbox": {
            "@id": "ldp:inbox",
            "@type": "@id"
        },
        "outbox": {
            "@id": "as:outbox",
            "@type": "@id"
        },
        "following": {
            "@id": "as:following",
            "@type": "@id"
        },
        "followers": {
            "@id": "as:followers",
            "@type": "@id"
        },
        "streams": {
            "@id": "as:streams",
            "@type": "@id"
        },
        "preferredUsername": "as:preferredUsername",
        "endpoints": {
            "@id": "as:endpoints",
            "@type": "@id"
        },
        "uploadMedia": {
            "@id": "as:uploadMedia",
            "@type": "@id"
        },
        "proxyUrl": {
            "@id": "as:proxyUrl",
            "@type": "@id"
        },
        "liked": {
            "@id": "as:liked",
            "@type": "@id"
        },
        "oauthAuthorizationEndpoint": {
            "@id": "as:oauthAuthorizationEndpoint",
            "@type": "@id"
        },
        "oauthTokenEndpoint": {
            "@id": "as:oauthTokenEndpoint",
            "@type": "@id"
        },
        "provideClientKey": {
            "@id": "as:provideClientKey",
            "@type": "@id"
        },
        "signClientKey": {
            "@id": "as:signClientKey",
            "@type": "@id"
        },
        "sharedInbox": {
            "@id": "as:sharedInbox",
            "@type": "@id"
        },
        "Public": {
            "@id": "as:Public",
            "@type": "@id"
        },
        "source": "as:source",
        "likes": {
            "@id": "as:likes",
            "@type": "@id"
        },
        "shares": {
            "@id": "as:shares",
            "@type": "@id"
        },
        "alsoKnownAs": {
            "@id": "as:alsoKnownAs",
            "@type": "@id"
        }
    }
}

from titanium-json-ld.

filip26 avatar filip26 commented on August 19, 2024

Hi @naturzukunft thank you for raising the issue. I'm just not sure how Titanium can help with that. What's your idea?

from titanium-json-ld.

filip26 avatar filip26 commented on August 19, 2024

closed due inactivity, feel free to re-open with new information.

from titanium-json-ld.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.