Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inverse properties using the @reverse keyword #731

Closed
albertemozo opened this issue Sep 6, 2016 · 3 comments
Closed

Inverse properties using the @reverse keyword #731

albertemozo opened this issue Sep 6, 2016 · 3 comments

Comments

@albertemozo
Copy link

Is there a way to use the JSON-LD @reverse keyword to invert properties?

Like in:

{
  "@context": "http://schema.org",
  "@id": "#homer",
  "@type": "Person",
  "name": "Homer",
  "@reverse": { "parent": [
      {
        "@id": "#bart",
        "@type": "Person",
        "name": "Bart"
      },
      {
        "@id": "#lisa",
        "@type": "Person",
        "name": "Lisa"
      }
    ]
  }
}

If not supported, what would be the correct way to represent a bidirectional relationship, if one of the sides is not present within the RDFA, from that particular side?

JSON-LD Specification
Schema.org docs

@teohhanhui
Copy link
Contributor

Example 48 in the JSON-LD spec looks much more usable to me. Having all the reverse properties under @reverse seems so unintuitive...

@albertemozo
Copy link
Author

albertemozo commented Sep 7, 2016

I chose Example 47 after having failed my attempts to have Google's Structured Data Testing Tool parse Example 48 without errors.

In particular, I tried with this alternative:

{
  "@context": {
    "@vocab": "http://schema.org",
    "children": { "@reverse": "parent" }
  },
  "@id": "#homer",
  "@type": "Person",
  "name": "Homer",
  "children": [
    {
      "@id": "#bart",
      "@type": "Person",
      "name": "Bart"
    },
    {
      "@id": "#lisa",
      "@type": "Person",
      "name": "Lisa"
    }
  ]
}

Getting the following error:

There was an invalid type in your JSON-LD.

And also resulting in a different data structure.

So I'm not sure about what could be the best implementation, any of them would be great.

@teohhanhui
Copy link
Contributor

This should have been fixed by #752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants