W3C home > Mailing lists > Public > public-linked-json@w3.org > February 2015

RE: [FHIR JSON-LD] How best to handle or avoid blank nodes?

From: Markus Lanthaler <markus.lanthaler@gmx.net>
Date: Fri, 27 Feb 2015 09:23:19 +0100
To: <public-linked-json@w3.org>
Message-ID: <005501d05266$a4fa3ff0$eeeebfd0$@gmx.net>
On 26 Feb 2015 at 21:35, David Booth wrote:
> On 02/25/2015 10:11 AM, Manu Sporny wrote:
>> So, count us in - send the questions to the mailing list and it looks
>> like you have multiple community members that would be willing to help out.
> 
> Thanks Manu (and Markus and Jim and any others)!   Okay, my first
> question regards blank nodes.
> 
> Here is an except of a FHIR JSON data:
> 
> {
>    "dob": "1972-11-30",
>    "_dob": {
>      "id": "314159",
>      "extension": [{
>         "url" : "http://example.org/fhir/extensions#text",
>         "valueString" : "Easter 1970"
>      }]
> }

Have you considered expanding dob and _dob to the same URL? Something like:

  {
      "@context": {
          "@vocab": "http://example/fhir/vocab#",
          "xsd": "http://www.w3.org/2001/XMLSchema#",
          "dob": { "@type": "xsd:date" },
          "_dob": { "@id": "dob", "@type": "@id" },
          "extension": { "@container": "@list" }
      },
      "dob": "1972-11-30",
      "_dob": {
          "id": "314159",
          "extension": [
              {
                  "url": "http://example.org/fhir/extensions#text",
                  "valueString": "Easter 1970"
              }
          ]
      }
  }

This yields (please note extension is a list):

  _:b0 <http://example/fhir/vocab#dob> "1972-11-30"^^<http://www.w3.org/2001/XMLSchema#date> .
  _:b0 <http://example/fhir/vocab#dob> _:b1 .
  _:b1 <http://example/fhir/vocab#extension> _:b3 .
  _:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _:b2 .
  _:b3 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
  _:b1 <http://example/fhir/vocab#id> "314159" .
  _:b2 <http://example/fhir/vocab#url> "http://example.org/fhir/extensions#text" .
  _:b2 <http://example/fhir/vocab#valueString> "Easter 1970" .


You can transform these triples back to 

  {
      "@context": ...
      "@graph": [
          {
              "@id": "_:b0",
              "dob": "1972-11-30"m
              "_dob": {
                  "@id": "_:b1",
                  "id": "314159",
                  "extension": [
                      {
                          "@id": "_:b2",
                          "url": "http://example.org/fhir/extensions#text",
                          "valueString": "Easter 1970"
                      }
                  ],
              }
          }
      ]
  }

with the following frame:

  {
      "@context": {
          "@vocab": "http://example/fhir/vocab#",
          "xsd": "http://www.w3.org/2001/XMLSchema#",
          "dob": { "@type": "xsd:date" },
          "_dob": { "@id": "dob", "@type": "@id" },
          "extension": { "@container": "@list" }
      },
      "dob": {}
  }


HTH,
Markus


--
Markus Lanthaler
@markuslanthaler
Received on Friday, 27 February 2015 08:23:49 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 16:18:43 UTC