zg009 / solid-subscription-server

0 stars 0 forks source link

NSS notifications document format json-ld or turtle #2

Open bourgeoa opened 7 months ago

bourgeoa commented 7 months ago

Shall we use JSON-LD or turtle ?

I personally prefer to work with turtle document. Notifications seems to have a very simple @context.

None the less NSS has no experience in JSON-LD and I'm not 100% sure in the conversion made with Rdflib

zg009 commented 7 months ago

I was using JSON-LD as it is the preferred format according to the specification. However, converting the existing types to have turtle outputs instead of JSON-LD is not too much trouble.

If necessary, I can always use https://github.com/digitalbazaar/jsonld.js to parse to RDF and then use rdflib to format a turtle file from the output. It also can use a custom RDF parser according to docs, but I have not used this library before.

zg009 commented 7 months ago

@bourgeoa I will go with Turtle files, but you will have to help me learn how to format them using RDFLib, as I am not rdflib experienced user or very familiar with RDF formats. Test in https://github.com/zg009/solid-subscription-server/blob/03bb6357eff5654e334911d2a8e73219d0f9f083/test/subscriptionService.spec.ts#L26-L30 are failing, rdflib not playing nicely or I did JSON-LD formatting wrong.

Suggestion is to replace generateDoc() with turtle format instead of JSONLD.

Also I am using Jest now because Mocha/chai were giving issues. But they are mostly the same.

bourgeoa commented 7 months ago

I tried to put

{"@context":["https://www.w3.org/ns/solid/notification/v1"],"id":"http://localhost:6060/subscription-service.ttl","channelType":0}

in https://json-ld.org/playground/ Do not seem valid due to "https://www.w3.org/ns/solid/notification/v1" because not exiting in real world I'm not sure we have really a valid json-ld. But may be only JSON. @context is not used

zg009 commented 7 months ago

@bourgeoa Yes, that is why for now I think generating documents using Turtle format is best. If there is need in the future, can add a function which creates JSON-LD format, or users can just use turtle to jsonld parser.