webidcg / webid-context

webid context
https://webidcg.github.io/webid-context/webid.json
MIT License
1 stars 2 forks source link

Add WebID JSON-LD examples #2

Open melvincarvalho opened 2 years ago

melvincarvalho commented 2 years ago

3 great WebID JSON-LD examples were described on the mailing list by @acoburn

Example 1

A JSON-LD WebID document might look like this

{
    "@context": [
      "https://home.apache.org/~acoburn/context/webid.json"
    ],
    "id": "https://id.example/acoburn#i",
    "type": ["Person"],
    "name": "Aaron Coburn",
    "primaryTopicOf": {
      "id": "https://id.example/acoburn",
      "type": ["PersonalProfileDocument"]
    }
}

Example 2

One could also reverse the Information Resource -- WebID relationship

{
    "@context": [
      "https://home.apache.org/~acoburn/context/webid.json"
    ],
    "id": "https://id.example/acoburn",
    "type": ["PersonalProfileDocument"],
    "primaryTopic": {
        "id": "https://id.example/acoburn#i",
        "type": ["Person"],
        "name": "Aaron Coburn"
    }
}

Example 3

If you want to layer another system -- say, for example, Solid -- on top of this, it is easy with a separate context

{
    "@context": [
      "https://home.apache.org/~acoburn/context/webid.json",
      "https://home.apache.org/~acoburn/context/solid.json"
    ],
    "id": "https://id.example/acoburn#i",
    "type": ["Person"],
    "name": "Aaron Coburn",
    "storage": ["https://solid.example/1", "https://solid.example/2"],
    "oidcIssuer": ["https://idp.example"],
    "primaryTopicOf": {
      "id": "https://id.example/acoburn",
      "type": ["PersonalProfileDocument"]
    }
}

Using this issue as a place holder to collect this and other JSON examples of what a WebID might look like. It can then be added somewhere to the repo documentation

kidehen commented 2 years ago

Example 4

## JSON-LD Start ##
{
    "@context": {
        "name": {
            "@id": "http://schema.org/name",
            "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
        },
        "sameAs": {
            "@id": "http://www.w3.org/2002/07/owl#sameAs",
            "@type": "@id"
        },
        "description": {
            "@id": "http://schema.org/description",
            "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
        },
        "mainEntityOfpage": {
            "@id": "http://schema.org/mainEntityOfpage",
            "@type": "@id"
        },
        "mainEntity": {
            "@id": "http://schema.org/mainEntity",
            "@type": "@id"
        },
        "title": {
            "@id": "http://schema.org/title",
            "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
        }
    },
    "@graph": [{
        "@id": "https://lists.w3.org/Archives/Public/public-webid/2022Jan/0115.html#netid",
        "@type": "http://schema.org/Person",
        "sameAs": [
            "https://twitter.com/kidehen#netid",
            "https://linkedin.com/in/kidehen#netid"
        ],
        "name": {
            "@value": "Kingsley Uyi Idehen",
            "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
        },
        "description": {
            "@value": "A document about me",
            "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
        },
        "mainEntityOfpage": {
            "@id": "https://lists.w3.org/Archives/Public/public-webid/2022Jan/0115.html#doc",
            "@type": "http://schema.org/WebPage",
            "mainEntity": "https://lists.w3.org/Archives/Public/public-webid/2022Jan/0115.html#netid",
            "title": {
                "@value": "A Personal Profile Document",
                "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
            }
        }
    }]
}
## JSON-LD End ##
kidehen commented 2 years ago

Example 5

Here's a rendition using Relative HTTP URIs from JSON-LD. Note, this is only now feasible due to fixes in JSON-LD 1.1.

## JSON-LD Start ##
{
  "@context": {
    "@base": "",
    "name": {
      "@id": "http://schema.org/name",
      "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
    },
    "sameAs": {
      "@id": "http://www.w3.org/2002/07/owl#sameAs",
      "@type": "@id"
    },
    "description": {
      "@id": "http://schema.org/description",
      "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
    },
    "mainEntityOfpage": {
      "@id": "http://schema.org/mainEntityOfpage",
      "@type": "@id"
    },
    "mainEntity": {
      "@id": "http://schema.org/mainEntity",
      "@type": "@id"
    },
    "title": {
      "@id": "http://schema.org/title",
      "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
    }
  },
  "@graph": [
    {
      "@id": "#netid",
      "@type": "http://schema.org/Person",
      "sameAs": [
        "https://twitter.com/kidehen#netid",
        "https://linkedin.com/in/kidehen#netid"
      ],
      "name": {
        "@value": "Kingsley Uyi Idehen",
        "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
      },
      "description": {
        "@value": "A document about me",
        "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
      },
      "mainEntityOfpage": {
        "@id": "doc",
        "@type": "http://schema.org/WebPage",
        "mainEntity": "#netid",
        "title": {
          "@value": "A Personal Profile Document",
          "@type": "http://www.w3.org/1999/02/22-rdf-syntax-ns#langString"
        }
      }
    }
  ]
}
## JSON-LD End ##