Skip to content

Instantly share code, notes, and snippets.

@donaldpipowitch donaldpipowitch/README.md
Last active Aug 28, 2017

Embed
What would you like to do?
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
You can’t perform that action at this time.