Re: GRDDLing JSON?

Hi Danny,

the `@context` stuff in JSON-LD is fairly powerful, and you can "hide" quite a lot of the intricacies. I am not an expert in creating context files, but I think your example could become something like

{
    "@context": "https://urltoyourcontext",
    "name": "t:SimplePipe",
    "pipe": [
        "StringSource",
        "AppendProcess",
        "StringSink"
    ]
}

Where the prefix 't' is defined in the context, and the context creates aliases for "name" (aliased it to "@id"), "pipe", makes it sure that "pipe" is mapped to a list, etc.

JSON-LD context is certainly not a panacea, and I am sure there are situations it cannot handle properly. It can also turn into something very complex needing a steep learning curve, but that is not much different from XSLT. 

Ivan



> On Feb 9, 2024, at 20:48, Danny Ayers <danny.ayers@gmail.com> wrote:
> 
> Have you tried it Dan? I expected the context to give a lot more.
> What I have seen :
> 
> {
>     "name": "SimplePipe",
>     "pipe": [
>         "StringSource",
>         "AppendProcess",
>         "StringSink"
>     ]
> }
> 
> becomes
> 
> {
>     "@context": {
>         "t": "http://purl.org/stuff/transmission/"
>     },
>     "@id": "https://hyperdata.it/treadmill/simplepipe.json",
>     "t:net": {
>         "@list": [
>             "StringSource",
>             "AppendProcess",
>             "StringSink"
>         ]
>     }
> }
> 
> 
> This an early version, those things in the list are actually classes, the instances need IDs/URIs (not sure what I've done with that version...). But you can already see obfuscation 
> 
> It gets less appealing the more you add. 
> 
> Unless someone has "Tim's Summer School Project"* very high on their job description, they will run a mile.
> 
> Why not just have eg. :
> 
> {
>     "transformer" : "http//purl.org/stuff/pipey-json-to-turtle.js <http://purl.org/stuff/pipey-json-to-turtle.js>", 
>     "name": "SimplePipe",
>     "pipe": [
>         "StringSource",
>         "AppendProcess",
>         "StringSink"
>     ]
> }
> 
> An agent can deref the link, make it RDF transparently. The typical JSON being dealt will have some kind of consistent schema that's hypothetically mapped to a global meaning, which can be declared using a name-value pair (plus written convention somewhere).    
> 
> 
> 
> * I forget the exact (awful) quote, something like that was Tim Bray's description of the Semantic Web
> 
> 
>  
> 
> 
> 
> On Fri, 9 Feb 2024 at 19:42, Dan Brickley <danbri@danbri.org <mailto:danbri@danbri.org>> wrote:
>> 
>> You can do quite a lot of mapping vanilla json into json-ld using json-ld contexts. Unlike xml there are only so many ways to say stuff and the content tends towards being objects and properties anyhow.
>> 
>> If you’re going to have a turing complete mapping framework you probably should just use JS. 
>> 
>> Cheers
>> 
>> Dan
>> 
>> On Fri, 9 Feb 2024 at 17:58, Danny Ayers <danny.ayers@gmail.com <mailto:danny.ayers@gmail.com>> wrote:
>>> I'm rather out of the loop, so apologies if something like this has already been discussed, implemented even. But I feel obliged to flag an issue, offer a potential solution (which might already exist).
>>> 
>>> # Use case :
>>> For the past few days I've been working on a bit of code where a processing pipeline will be set up declaratively. I'm still on baby steps, but it's a place where RDF should be ideal. A little graph defines the nodes & arcs of the processing system.
>>> 
>>> To get the code started, I only need a trivial model to work from. A simple list, (input reader)->(process)-> (output writer).
>>> So at this stage, it seemed reasonable just to use a minimal JSON list. Generalise to RDF later.
>>> There's a sequence of nodes, each with an instance ID and a type for the nature of the thing. 
>>> A very simple JSON structure covers it.
>>> 
>>> # Issue :
>>> But looking ahead, I wondered how to migrate from the arbitrary JSON to an RDF model. Obviously, JSON-LD.
>>> In my head I saw a namespace declaration, the rest just lifted & placed there from the keys in the JSON mappings. But in practice, it's not quite like that, it gets ugly fast.
>>> I guess it's basically a syntax issue.
>>> What you see in the (arbitrary) JSON expression is visually/intuitively understandable. Ditto in Turtle. But in JSON-LD, any kind, the immediacy of interpretation by a human (this one at least)  is lost.
>>> 
>>> # Proposed Solution :
>>> I don't know if anyone remembers GRDDL [1]. An elegant approach for bridging between anyXML and RDF.  One added attribute in the doc, to say it has an RDF representation and here's how to get it. It's an easy inclusion in namespaced XML, we* went for XSLT transformers, a very immediate approach. Imagine an org with loads of XML documents of the same shape. A transformation has to be written once, that pointer inserted in all these docs, very low-effort mapping to the RDF world.
>>> As far as I'm aware, to date, absolutely no-one has ever used this.
>>> 
>>> *But* the idea is great. Forget XML, let's do JSON.
>>> Add one (presumably top-level) name value pair in a JSON doc:
>>> 
>>> { "http://www.w3.org/2003/g/data-view#", "http://example.org/this-to-that"
>>> ...
>>> }
>>> 
>>> At http://example.org/this-to-that you have the definition of how to take this arbitrary JSON and make it a citizen of the Web.
>>> 
>>> I'll say again, you might well just want to bin this if such things have been dealt with already.
>>> But it did strike me that in practice, I was facing horrible stuff to look at. Please remember RDF/XML's role in adoption.
>>>   
>>> Cheers,
>>> Danny.
>>> 
>>> [1] https://www.w3.org/TR/grddl/
>>> 
>>> * yeah, I was on the GRDDL Working Group. Memory totally gone over my contributions, but in these things I generally only offer /wrong/ arguments (realise years later), which post-factum I convince myself are useful to get the people with their heads screwed on to look at things more closely. 
>>> I'm still a little irritated I didn't get a credit in the doc, I poked Dan Connolly and he said he's sort it, Didn't. It did mean something to me, one of the very few things I've been involved with which had a very pleasing end product (even if absolutely no-one uses it). 
>>>  
>>> I should also confess I was mouthy in the JSON-LD group at the start, but quietly shuffled away when I realised the other folks had magnitudes better grasp.  
>>> 
>>> --
>>> ----
>>> 
>>> https://hyperdata.it <http://hyperdata.it/danja>
>>> 
> 
> 
> --
> ----
> 
> https://hyperdata.it <http://hyperdata.it/danja>
> 


----
Ivan Herman, W3C 
Home: http://www.w3.org/People/Ivan/
mobile: +33 6 52 46 00 43

Received on Saturday, 10 February 2024 11:30:28 UTC