Re-using JSON-LD knowledge data - schema.org

I can't determine if it's possible to reference a pairs value after it has been defined.
For example if I create an address pair, can I then use a shorthand way of re-using that value?
"address": {
"#type": "PostalAddress",
"streetAddress": "14 Blue Street Road",
"addressLocality": "Nottingham",
"addressRegion": "Nottinghamshire
"postalCode": "NG73DT",
"addressCountry": "United Kingdom"
},
"foundingLocation": "#address",

Yes, this is possible. JSON-LD links nodes using properties. Nodes are either value objects (e.g., dates, times, numbers, etc.) or node objects, such as your PostalAddress above. All nodes have an identifier, either explicit or implement, specified using the #id property. The JSON-LD Flattening algorithm, among others, has a process where it removes embedded node definitions, and replaces them with references, creating a blank node as required. A reference is basically just a node containing only the #id property. Your example above could be re-written by adding a blank node to the PostalAddress:
"address": {
"#id": "_:n1",
"#type": "PostalAddress",
"streetAddress": "14 Blue Street Road",
"addressLocality": "Nottingham",
"addressRegion": "Nottinghamshire
"postalCode": "NG73DT",
"addressCountry": "United Kingdom"
},
"foundingLocation": "#address",
You can then reference this from foundingLocation as follows:
"address": {
"#id": "_:n1",
"#type": "PostalAddress",
"streetAddress": "14 Blue Street Road",
"addressLocality": "Nottingham",
"addressRegion": "Nottinghamshire
"postalCode": "NG73DT",
"addressCountry": "United Kingdom"
},
"foundingLocation": {"#id": "_:n1"}

Related

Adding Schema.org 'Brand' in JSON-LD

I have been adding rich snippets to my ecommerce store, and for the most part I have had no problems. For some reason when I go to add in the "brand" that is recommeneded by Google and Google Merchant services I have problems.
I have added this under: http://schema.org/Offer. And by adding it in the script in my header also with no luck.
<script type="application/ld+json" data-resource-group="head_tag" data-resource-code="organization_schema">{
"#context": "http://schema.org",
"#type": "Organization",
"address": {
"#type": "PostalAddress",
"addressLocality": "",
"addressRegion": "",
"addressCountry": "",
"postalCode": "",
"streetAddress": ""
},
"email": "customerservice#domain.com",
"name": "Comany namee",
"telephone": "company number"
},
"brand":{
"#type":"Thing",
"name":"[manufacture_name]"
},
</script>
<meta itemprop="brand" content="[manufacturer_name]" />
"brand":{
"#type":"Thing",
"name":"[manufacture_name]"
},
The second one just simply isn't detected for some reason.
I have code similar to the meta tag throughout the documnet so I would prefer to keep with that format if possible.
Your JSON-LD has syntax errors:
The Organization is closed with },, but the brand property appears after it.
A closing } is missing.
There should be no , after the last }.
So it would be:
{
"#context": "http://schema.org",
"#type": "Organization",
"address": {
"#type": "PostalAddress"
},
"name": "company name",
"brand": {
"#type": "Brand",
"name": "manufacturer name"
}
}
(Note that I used Brand instead of Thing.)

Connecting multiple organizations and websites via JSON-LD schema.org

I'm trying to accomplish machine-understandable relationship descriptions for companies/subsidiaries and their websites. Let's suppose there is one parent company with two subsidiaries, all of which have their own websites. I deploy one Organization script, and one WebSite script per home page.
The parent organization's JSON-LD reads:
<script type="application/ld+json">
{
"#context": "http://www.schema.org",
"#type": "Organization",
"#id": "https://www.parentorg.com/#organization",
"name": "Parent Org",
"legalName": "Parent Org Inc.",
"description": "Description of company",
"foundingDate": "1978",
"logo": "https://www.parentorg.com/images/logo.png",
"image": "https://www.parentorg.com/de/images/outside.jpg",
"url": "https://www.parentorg.com/",
"address": {
"#type": "PostalAddress",
"streetAddress": "Street 110",
"addressLocality": "City",
"postalCode": "XX XXX",
"addressCountry": "XX"
},
"contactPoint": {
"#type": "ContactPoint",
"contactType": "customer support",
"telephone": "+12-345-678-91011",
"email": "contact#parentorg.com"
},
"sameAs": [
"https://twitter.com/parentorg/",
"https://www.instagram.com/parentorg/",
"https://www.youtube.com/user/parentorg/",
"https://plus.google.com/parentorg"
],
"subOrganization": [
{
"#type": "Organization",
"#id": "https://www.subsidiary-one.de/#organization",
"name": "Subsidiary One"
},
{
"#type": "Organization",
"#id": "https://www.subsidiary-two.de/#organization",
"name": "Subsidiary Two"
}
]
}
</script>
The parent's website JSON-LD is:
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "WebSite",
"#id": "https://www.parentorg.com/#website",
"url": "https://www.parentorg.com/",
"author": {
"#type": "Organization",
"#id": "https://www.parentorg.com/#organization",
"name": "Parent Org"
}
}
</script>
And now the subsidiaries' organization JSON-LD contain a parentOrganization property:
"parentOrganization": {
"#type": "Organization",
"#id": "https://www.parentorg.com/#organization",
"name": "Parent Org"
}
Would this be a good way to cross-reference those entities? And do I even need to write out the name properties inside subOrganization, parentOrganization, and author, when there are URIs referenced?
Yes, you follow the best practice how to cross-reference entities (by giving each entity an #id that is different from the url).
You don’t have to provide additional properties when referencing entities, so this is fine:
"author": {"#id": "https://www.parentorg.com/#organization"}
"subOrganization": [
{"#id": "https://www.subsidiary-one.de/#organization"},
{"#id": "https://www.subsidiary-two.de/#organization"}
]
"parentOrganization": {"#id": "https://www.parentorg.com/#organization"}
However, this of course requires that consumers fetch the referenced documents. But not all do (probably). So if you want to provide data for those consumers, too, you could add properties in addition to the #id. It could be just one, a few, or even all properties. I think the two from your example are the most important ones:
Providing #type can also be useful for consumers that are capable of fetching documents, as it may allow them to decide whether the referenced resource is of interest to them before fetching it. For example, a consumer might only care about works authored by an Organization, not by a Person.
Providing the name property can be useful for consumers that display the included structured data in some way that benefits from a name/label.

do type=#id values have to be explicitly typed in JSON-LD?

I'm looking into JSON-LD specifically in combination with schema.org.
one of the Json-LD examples of schema.org/Person struck me as wrong:
{
"#context": "http://schema.org",
"#type": "Person",
"address": {
"#type": "PostalAddress",
"addressLocality": "Seattle",
"addressRegion": "WA",
"postalCode": "98052",
"streetAddress": "20341 Whitworth Institute 405 N. Whitworth"
},
"colleague": [
"http://www.xyz.edu/students/alicejones.html",
"http://www.xyz.edu/students/bobsmith.html"
],
"email": "mailto:jane-doe#xyz.edu",
"image": "janedoe.jpg",
"jobTitle": "Professor",
"name": "Jane Doe",
"telephone": "(425) 123-4567",
"url": "http://www.janedoe.com"
}
What seems wrong to me is that colleague is defined to be of type=Person (see above link), but instead an entity reference (url/text) is supplied.
The proper way to format this seems to be supplying extra info in the #context like so:
{
"#context": {
"#vocab": "http://schema.org/",
"colleague": { "#type": "#id" }
},
"#type": "Person",
"address": {
"#type": "PostalAddress",
"addressLocality": "Seattle",
"addressRegion": "WA",
"postalCode": "98052",
"streetAddress": "20341 Whitworth Institute 405 N. Whitworth"
},
"colleague": [
"http://www.xyz.edu/students/alicejones.html",
"http://www.xyz.edu/students/bobsmith.html"
],
"email": "mailto:jane-doe#xyz.edu",
"image": "janedoe.jpg",
"jobTitle": "Professor",
"name": "Jane Doe",
"telephone": "(425) 123-4567",
"url": "http://www.janedoe.com"
}
Is the example on schema.org (code example 1) indeed incorrect/incomplete, and is code example 2 correct?
Or in general: when referencing instead of embedding entities, is it required to make this explicit (using #type: #id) or, alternatively, is there some implicit notion in the spec that when a value is an URL it's considered to be a reference by #id?
You are right, the example is not 100% correct. The type-coercion to #id is missing. I filed a bug to get this fixed: https://github.com/schemaorg/schemaorg/issues/929

Adding a 'license' field to a schema.org Place record

I have a database of locations that I would like to publish as Open Data. each record can have one of several licenses depending on where the data was sourced from so each record needs to have a license attached. I'm publishing the data as json-ld. Sample record:
{
"#context": "http://schema.org",
"#type": "Place",
"name": "METROPOLITAN MUSEUM OF ART",
"address": {
"#type": "PostalAddress",
"streetAddress": "1000 5TH AVE",
"addressLocality": "NEW YORK",
"addressRegion": "NY",
"addressCountry": "United States",
"postalCode": "10028-0198"
},
"hasMap": "http://www.openstreetmap.org/?mlat=40.7784&mlon=-73.9627#map=15/40.7784/-73.9627",
"geo": {
"#type": "GeoCoordinates",
"latitude": 40.7784,
"longitude": -73.9627
},
"description": null,
"telephone": "+1 (212) 472-2764",
"url": "http://www.metmuseum.org",
"openingHours": null,
"photo": {
"#type": "ImageObject",
"contentUrl": "http://127.0.0.1:8888/fSunhLAJFSmnx55GNJee2-YKcgE=/1000x1000/museums/logos/000/149/449/original/NYC_-_Metropolitan_-_Temple_of_Dendur.JPG",
"creator": "Jean-Christophe BENOIST",
"license": "CC BY 3.0"
}
}
The schema.org Place model doesn't have a field for 'license'. What is the correct way to add a license type field to the record? Essentially I want to embed a CreativeWork field in there if possible.
It seems that you want to provide a license for the document that is about the Place, not for the Place itself.
So go with CreativeWork (or one of its sub-types, like WebPage if the document is a web page) and make use of its license property.
To state that this CreativeWork is about the Place, you could use the about property, and to state that the Place is the primary entity described in this document, you could use the mainEntity property.
If you want to keep Place as the top-level node, you could use JSON-LD’s #reverse for the about property, and use mainEntity’s inverse property, mainEntityOfPage.
Using http://schema.org/Dataset (which is a type of CreativeWork) will allow you to set a license. Place is a field within Dataset so they fit together. The license for your ImageObject should also be the URL of the license not the text (which I found out after having issues with it).
Dataset includes datasetTimeinterval, distribution, includedDataCatalog and spatial (a Place). Dataset was only introduced in May

How to test the Google Schemas

I am trying to implement the ParcelDelivery feature for my webshop as shown here:
https://developers.google.com/gmail/markup/reference/parcel-delivery
The markup i use validates using this tool:
https://www.google.com/webmasters/markup-tester/
On the help pages it shows that you can test this markup by sending an email from yourself, to yourself. So i am sending myself an email using the GMail web interface, but no matter what i use for the formatting (plain text or html) the "package delivery status" does not show up in my inbox.
Instead, when i click to open the email; the entire code below is shown as the email, just if GMail does not pick it up.
p.s. is this schema also supported in the NOW cards? does anybody know?
Am i doing something wrong?
This is my source used:
<html>
<body>
<script type="application/ld+json">
{
"#context": "http://schema.org",
"#type": "ParcelDelivery",
"deliveryAddress": {
"#type": "PostalAddress",
"name": "John Frank",
"streetAddress": "24 Willie Mays Plaza",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"addressCountry": "US",
"postalCode": "94107"
},
"originAddress": {
"#type": "PostalAddress",
"name": "John Frank",
"streetAddress": "25 Willie Mays Plaza",
"addressLocality": "San Francisco",
"addressRegion": "CA",
"addressCountry": "US",
"postalCode": "94107"
},
"expectedArrivalFrom": "2013-03-10T12:00:00-08:00",
"expectedArrivalUntil": "2013-03-12T12:00:00-08:00",
"carrier": {
"#type": "Organization",
"name": "FedEx",
"url": "http://fedex.com/"
},
"itemShipped": {
"#type": "Product",
"name": "iPod Mini",
"url": "http://apple.com/ipad32gb",
"image": "http://apple.com/images/ipad32gb.jpg",
"sku": "B00DR0PDNE",
"description": "iPod Mini 32Gb White",
"brand": {
"#type": "Brand",
"name": "Apple"
},
"color": "white"
},
"trackingNumber": "3453291231",
"trackingUrl": "http://fedex.com/track/3453291231",
"hasDeliveryMethod": "http://schema.org/ParcelService",
"partOfOrder": {
"#type": "Order",
"orderNumber": "176057",
"merchant": {
"#type": "Organization",
"name": "Bob Dole",
"sameAs": "http://www.freebase.com/m/0fhkx"
},
"orderStatus": "http://schema.org/OrderInTransit"
}
}
</script>
<p>
Dear John, thanks for booking your Google I/O ticket with us.
</p>
<p>
BOOKING DETAILS<br/>
Reservation number: IO12345<br/>
Order for: John Smith<br/>
Event: Google I/O 2013<br/>
Start time: May 15th 2013 8:00am PST<br/>
Venue: Moscone Center, 800 Howard St., San Francisco, CA 94103<br/>
</p>
</body>
</html>