I was wondering, is there a way to use the HAL concepts with JSON-LD?
I have the current jsonld document:
{
"#context": {
"hal": "http://stateless.co/hal#",
"schema": "http://schema.org",
"_links": {
"#id": "hal:link",
"#container": "#index"
}
},
"#type": ["schema:Person", "hal:Resource"],
"name": "Jon Snow",
"_links": {
"self": {
"href": "/users/123"
}
}
}
but I am not sure how to define that the href has a #type of #id, and so on...
Is there a way to define a HAL vocab based on RDF(S) and import it somehow in the #context of my jsonld documents, or should I do something else?
(I am trying to describe hyperlinks with various properties, like link relation, HTTP method, accepted media type, language, IRI template, input fields, etc... so the #id type is not enough for me to describe links.)
As Tomasz already suggested, you should really consider using Hydra as it does more or less what you want. The example you've included in your questions, would look somewhat like this using Hydra and JSON-LD:
{
"#context": {
"schema": "http://schema.org",
"ex": "http://example.com/myvocab#"
},
"#id": "/users/123",
"#type": [ "schema:Person", "hydra:Resource" ],
"name": "Jon Snow",
"ex:link": { "#id": "/another-resource" }
}
As there's no need for a "self" link (#id already specifies that explicitly), I've added another link, ex:link. Its link relation is consequently http://example.com/myvocab#link and its "href" is /another-resource. If you need to describe that link/property in more details, you can do so by creating a document which defines it in exactly the same manner as other things are described (as Tomasz also already explained):
{
"#context": {
"ex": "http://example.com/myvocab#",
"hydra": "http://www.w3.org/ns/hydra#"
},
"#id": "ex:link",
"#type": "hydra:Link",
"hydra:title": "My new link relation",
"hydra:supportedOperation": [
{
"#type": "hydra:Operation",
"hydra:method": "POST",
"hydra:expects": ....
}
]
}
Regarding your comment
Btw. I am more or less familiar with the Hydra vocab, but I don't like
the idea to map the resources to real classes and objects on a server
side language and automatically transform the operation parameters
into those objects. Maybe it is possible to use the Hydra vocab in
another way, but I don't have the time to experiment with that.
Hydra is really just a vocabulary. It is up to you to decide how to use it. I think you are talking about the HydraBundle above. That's just one way to use it. It is just a proof of concept to show that it is easily possible. So please don't get confused by that.
I would like to invite you to join the Hydra W3C Community Group. We can then discuss this in more detail on our mailing list.
Disclaimer: I'm the creator of Hydra and the chair of the Hydra W3C Community Group.
I think you could be interested in Hydra. Have you tried that?
It's a vocabulary for describing Hypermedia links and operations. Here's how it could work for a simple parent link
{
"#context": {
"schema": "http://schema.org",
"parent": {
"#id": "/vocab#parent"
"#type": "#id"
}
},
"#id": "/users/123",
"#type": "schema:Person",
"name": "Jon Snow",
"parent": "/users/Ned_Stark"
}
Note that you don't need to include any data outside your domain in the representation. Instead you describe what the parent predicate means
{
"#context": "http://www.w3.org/ns/hydra/context.jsonld",
"#id": "/vocab#parent",
"#type": "hydra:Link"
}
You can also describe operations (HTTP methods, ranges, domains, etc.) and properties for classes. Also the operations can be included directly in the representation or attached to the classes and proeprties.
Related
I'm attempting to make correct and efficient use of schema.org json-ld recommandations for adding semantic to a web page.
I have a web page for unique organizations (http://example/organization1):
{
"#context": "http://schema.org/",
"#type": "Organization",
"#id" : "#ID_Organization1",
"name": "Organization1",
"url": "https://myorganization1.com
}
Can I reuse the information on that organization on another page without having to redeclare it ? (http://example/offers)
{
"#context": "https://schema.org/",
"#type": "Review",
"itemReviewed" : {
"#type" : "Organization",
"#id" : "http://example/organization1#ID_Organization1"
},
}
Check the following JSON-LD 1.1 documentation information:
3.3 Node Identifiers
To be able to externally reference nodes
in an RDF graph, it is important that nodes
have an identifier. IRIs are a fundamental concept of Linked Data, for
nodes to be truly linked, dereferencing the identifier should result
in a representation of that node. This may allow an application to
retrieve further information about a node. In JSON-LD, a node is identified using the #id keyword.
This probably means that there is no limit to using this element.
I am implementing structured data into my website. When I consider Schema.org’s Article, publisher and author is the same Organization.
Is it a good practice to duplicate it in both properties? I am using JSON-LD to implement it.
In JSON-LD (in contrast to Microdata and RDFa), you have no choice other than to duplicate it.
However, you don’t necessarily have to provide the full Organization item in both places. Give your Organization a URI with #id, and then reference this URI in the other place:
"author": {
"#type": "Organization",
"#id": "/#org",
"url": "/",
"name": "Nosek Inc.",
"description": "Great organization"
},
"publisher": {"#id": "/#org"}
It often make sense to provide/duplicate at least some properties, though, e.g., important ones like #type, name, url etc.:
"publisher": {
"#type": "Organization",
"#id": "/#org",
"name": "Nosek Inc."
}
I've browsed the web for quite some time now, and have a good grasp on how Schema.org works. Now, it comes to mind that one could use Schema.org to let search engines know that this or that website is using particular software on the website, given that some functionality is provided to it. On the other hand, I can't find any references of major players doing so (WordPress, WooCommerce, Magento), so I was wondering:
How would I mark my piece of software, using Schema.org, on customer's website?
What exactly can I add as info to it (name, author, URLs, desc)?
Which types/properties should be used?
To add to point question 3, SoftwareApplication seems pretty much like something that would cover it. In Schema.org’s own examples, like following:
{
"#context": "http://schema.org",
"#type": "Restaurant",
"name": "Tartine Bakery",
"potentialAction": {
"#type": "ViewAction",
"target": [
"http://www.urbanspoon.com/r/6/92204",
{
"#type": "EntryPoint",
"urlTemplate": "http://api.urbanspoon.com/r/6/92204",
"contentType": "application/json+ld"
},
"android-app://com.urbanspoon/http/www.urbanspoon.com/r/6/92204",
{
"#type": "EntryPoint",
"urlTemplate": "urbanspoon://r/6/92204",
"actionApplication": {
"#type": "SoftwareApplication",
"#id": "284708449",
"name": "Urbanspoon iPhone & iPad App",
"operatingSystem": "iOS"
}
},
{
"#type": "EntryPoint",
"urlTemplate": "urbanspoon://r/6/92204",
"actionApplication": {
"#type": "SoftwareApplication",
"#id": "5b23b738-bb64-4829-9296-5bcb59bb0d2d",
"name": "Windows Phone App",
"operatingSystem": "Windows Phone 8"
}
}
]
}
}
Schema.org is used to provide info about an restaurant (why not software?). So, if anyone has an idea of how can this be done, it would be much appreciated.
Schema.org doesn’t offer a property to specify the SoftwareApplication that was used for generating a WebSite/WebPage.
The isBasedOn property might be used, given its broad definition ("A resource that was used in the creation of this resource."), but I guess it was not intended for this purpose.
Instead of specifying the software that is used for generating the pages (which is typically not interesting for consumers, especially since it doesn’t necessarily follow that certain features are available), it might make more sense to specify the potential actions offered by the site/pages:
RegisterAction
CommentAction
SearchAction
BuyAction
etc.
And from such an Action, you could use (where applicable) the target property to specify an EntryPoint which can specify with actionApplication which software is used to "complete the request".
(By the way, you can specify the software that was used to generate the HTML document as meta tag, no need for structured data: generator)
I am playing with Schema.org, creating extensions for Google Rich Snippets based on JSON-LD, using https://schema.org/Product.
{
"#context": "http://schema.org/",
"#type": "Product",
"name": "Executive Anvil",
"image": "http://www.example.com/anvil_executive.jpg",
"description": "Sleeker than ACME's Classic Anvil, the Executive Anvil is perfect for the business traveler looking for something to drop from a height.",
"mpn": "925872",
"brand": {
"#type": "Thing",
"name": "ACME"
}
}
But I do not understand which how long the value for description and name can be. Seems to me that this is a very important value.
The vocabulary Schema.org doesn’t restrict the length that Text values can have. Not for Product nor for any other type.
Consumers (like Google Search) might have their own rules/restrictions. These should, hopefully, be described in their documentation. For Google’s Products rich result, no restrictions are specified for name/description.
Google indicates between >50 and <5000
I'm trying to model the concept of folders (or directories) and files. Folders can contain files, or other folders (arbitrary nested recursive structure, like on your typical filesystem). I would ideally like to start with a schema.org context and base type, and extend that to represent these entities. For various reasons, I am also interested in using JSON-LD as the format.
After some research and looking into examples, it seems like using a
base of http://schema.org/CreativeWork, along with additionalType in conjunction with productontology.org is a relatively straightforward
way to express this. But is this a good way to express these concepts? I am open to using just about anything else, in place of an entry from productontology.org, as the additionalType, particularly if it allows me to express more meaningful properties than simply using those from CreativeWork.
Proposed folder example (playground link):
{
"#context": "http://schema.org/",
"#type": "CreativeWork",
"#id": "http://my-site.com/folder/1",
"additionalType": "http://www.productontology.org/doc/Directory_(computing)",
"name": "My Folder",
"url": "http://my-site.com/folder/1"
}
Proposed file example (playground link):
{
"#context": "http://schema.org/",
"#type": "CreativeWork",
"#id": "http://my-site.com/file/2",
"additionalType": "http://www.productontology.org/doc/Computer_file",
"name": "My File",
"isPartOf": {
"#context": "http://schema.org/",
"#type": "CreativeWork",
"#id": "http://my-site.com/folder/1",
"additionalType": "http://www.productontology.org/doc/Directory_(computing)",
"name": "My Folder",
"url": "http://my-site.com/folder/1"
},
"url": "http://my-site.com/file/2"
}
You might wanna consider the Nepomuk File Ontology (NFO) instead.