1

I am currently trying to use JSON-LD to make legacy JSON documents machine readable. Now I have a legacy document that contains a list of names. Each of these names references an entity for which I already have further knowledge in my graph and therefore I would like to link the existence of its name to the further attributes already known about it. But there is no IRI contained in the legacy JSON document, so when I convert it via JSON-LD, I just get unlinked string literals into my graph.

My legacy JSON document looks like this:

{
  "url": "https://example.com/123",
  "name": "Test",
  "children": [
    "Abc",
    "Def",
    "Xyz"
  ]
}

My JSON-LD context looks something like this currently:

{
  "@context": {
    "ex": "https://example.com/",
    "name": "ex:name",
    "children": "ex:has"
  }
}

And in my knowledge store I have something like this already before interpreting the legacy document:

@PREFIX ex: <https://example.com/>
ex:abc ex:name "ABC".
       ex:hasValue 123.
ex:def ex:name "DEF"
       ex:hasValue 456.
ex:xyz ex:name "XYZ".
       ex:hasValue 789.

Is there some supposed way to link the data attached i.e. to ex:xyz by the name "Xyz" in the legacy document? Or is there no other way than to write a custom program to add futher triples for these links?

I would like to see the following in my extracted knowledge from the legacy JSON:

ex:123 ex:name "Test".
       ex:has ex:abc.
       ex:has ex:def.
       ex:has ex:xyz.
aef
  • 4,498
  • 7
  • 26
  • 44
  • 1
    E.g.this: `"children": { "@id": "ex:has", "@type": "@id", "@context" : {"@base": "https://example.com/"}}` – Stanislav Kralin Dec 06 '20 at 21:33
  • 1
    Stanislav came up with the same thing I was going to suggest. Note that values of `@id` will always be interpreted as IRIs (absolute, relative, or compact) and terms won't expand, so you can't alias "Abc" to "https://example.com/abc", but you can set the base for expanding relative IRIs. – Gregg Kellogg Dec 06 '20 at 22:28
  • @StanislavKralin Ok thanks, that seems to work for my example. In reality though the children array also contains strings including whitespace. And as soon as a child has whitespace in it, e.g. `"Abc Def"`, at least the Ruby JSON-LD implementation ignores the `@type` and `@base` and just make it a literal string again. – aef Dec 07 '20 at 01:10

0 Answers0