Skip to content

Instantly share code, notes, and snippets.

@donaldpipowitch
Last active August 28, 2017 06:36
Show Gist options
  • Save donaldpipowitch/5595a76b5c312deea4584a3deb8fd486 to your computer and use it in GitHub Desktop.
Save donaldpipowitch/5595a76b5c312deea4584a3deb8fd486 to your computer and use it in GitHub Desktop.
JSON-LD examples

Not sure, if these are all valid.

I basically want to add links to my data. In HAL it probably would lool like this:

{
    "_links": {
        "self": {
            "href": "https://example.com/users/1"
        },
        "mother": {
            "href": "https://example.com/users/2"
        },
        "father": {
            "href": "https://example.com/users/3"
        }
    },
    "id": "1",
    "name": "Jon Doe"
}

JSON-LD self link examples

Payload with "inline unnamed self link":

{
  "@id": "https://example.com/users/1",
  "id": "1",
  "name": "Philipp Zins"
}

Payload with "inline named self link":

{
  "self": { "@id": "https://example.com/users/1" },
  "id": "1",
  "name": "Philipp Zins"
}

Payload with "named self link in @context":

{
  "@context": {
    "self": "@id"
  },
  "self": "https://example.com/users/1",
  "id": "1",
  "name": "Philipp Zins"
}

JSON-LD multiple links examples

Payload with multiple "inline named links":

{
  "@context": {
    "self": "@id"
  },
  "self": "https://example.com/users/1",
  "mother": {
    "@id": "https://example.com/users/2"
  },
  "father": {
    "@id": "https://example.com/users/3"
  },
  "id": "1",
  "name": "Jon Doe"
}

Payload with multiple "named links in @context":

{
  "@context": {
    "self": "@id",
    "mother": {
      "@id": "http://schema.org/parent",
      "@type": "@id"
    },
    "father": {
      "@id": "http://schema.org/parent",
      "@type": "@id"
    }
  },
  "self": "https://example.com/users/1",
  "mother": "https://example.com/users/2",
  "father": "https://example.com/users/3",
  "id": "1",
  "name": "Jon Doe"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment