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

feat(helpers): add JSON-LD @graph support #527

Merged
merged 2 commits into from
Apr 3, 2022
Merged

feat(helpers): add JSON-LD @graph support #527

merged 2 commits into from
Apr 3, 2022

Conversation

Kikobeats
Copy link
Member

@Kikobeats Kikobeats commented Apr 3, 2022

A JSON-LD structure can be defined using @graph property rather than just a single node.

{
  "@context": {
    "generatedAt": {
      "@id": "http://www.w3.org/ns/prov#generatedAtTime",
      "@type": "http://www.w3.org/2001/XMLSchema#dateTime"
    },
    "Person": "http://xmlns.com/foaf/0.1/Person",
    "name": "http://xmlns.com/foaf/0.1/name",
    "knows": {"@id": "http://xmlns.com/foaf/0.1/knows", "@type": "@id"}
  },
  "@id": "http://example.org/foaf-graph",
  "generatedAt": "2012-04-09T00:00:00",
  "@graph": [
    {
      "@id": "http://manu.sporny.org/about#manu",
      "@type": "Person",
      "name": "Manu Sporny",
      "knows": "https://greggkellogg.net/foaf#me"
    }, {
      "@id": "https://greggkellogg.net/foaf#me",
      "@type": "Person",
      "name": "Gregg Kellogg",
      "knows": "http://manu.sporny.org/about#manu"
    }
  ]
}

This PR normalizes the @graph in case it's present as a collection of objects, so metascraper can use them for finding a specific property.

closes #233

@coveralls
Copy link
Collaborator

coveralls commented Apr 3, 2022

Coverage Status

Coverage increased (+0.007%) to 97.887% when pulling 4350e07 on next into 2062907 on master.

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

Successfully merging this pull request may close these issues.

JSON-LD @graph parsing
2 participants