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

serialize identifier to ld+json @id #102

Merged
merged 2 commits into from
Sep 26, 2019
Merged

serialize identifier to ld+json @id #102

merged 2 commits into from
Sep 26, 2019

Conversation

Gummibeer
Copy link
Collaborator

@Gummibeer Gummibeer commented Sep 25, 2019

fixes #98
replaces #79

All schema.org syntaxes already have built-in representation for URIs and URLs, e.g. in Microdata 'itemid', in RDFa 1.1, 'resource', in JSON-LD, '@id'.

https://schema.org/docs/datamodel.html#identifierBg

@Gummibeer Gummibeer self-assigned this Sep 25, 2019
@Gummibeer Gummibeer merged commit 5ede7ed into master Sep 26, 2019
@Gummibeer Gummibeer deleted the ft-ld-json-id branch September 26, 2019 08:11
@Gummibeer
Copy link
Collaborator Author

@n0-m4d
Copy link

n0-m4d commented Oct 10, 2019

BC break for me. I need to set a property named identifier which is not being converted to @id. how can i do this now?

@Gummibeer
Copy link
Collaborator Author

It's kind of breaking but this package sticks to the schema.org ld+json standard. ANd this clearly states that the identifier property is replaced by/displayed as @id.

At the moment there is no way to keep identifier as a property. Why do you need it?

@n0-m4d
Copy link

n0-m4d commented Oct 10, 2019

google needs it. check https://developers.google.com/search/docs/data-types/job-posting and strg+f "identifier"

@Gummibeer
Copy link
Collaborator Author

It refers to the normal structured data testtool. Have you tried what Google shows if you use @id instead of identifier? Because Google wants to have the @id for normal page schema.

@n0-m4d
Copy link

n0-m4d commented Oct 10, 2019

the test tool says Das JSON-LD-Dokument enthält einen ungültigen Typ. respectively something like The JSON LD document contains an invalid type.

@Gummibeer
Copy link
Collaborator Author

Could you post your resulting schema ld+json? If you want you can replace all sensitive information but please keep up the whole structure as is.

@n0-m4d
Copy link

n0-m4d commented Oct 10, 2019

{
  "@context" : "https://schema.org/",
  "@type" : "JobPosting",
  "title" : "Software Engineer",
  "description" : "<p>Google aspires to be an organization that reflects the globally diverse audience that our products and technology serve. We believe that in addition to hiring the best talent, a diversity of perspectives, ideas and cultures leads to the creation of better products and services.</p>",
  "@id": {
    "@type": "PropertyValue",
    "name": "MagsRUs Wheel Company",
    "value": "1234567"
  },
  "datePosted" : "2017-01-18",
  "validThrough" : "2017-03-18T00:00",
  "employmentType" : "CONTRACTOR",
  "hiringOrganization" : {
    "@type" : "Organization",
    "name" : "Google",
    "sameAs" : "http://www.google.com",
    "logo" : "http://www.example.com/images/logo.png"
  },
  "jobLocation": {
  "@type": "Place",
    "address": {
    "@type": "PostalAddress",
    "streetAddress": "1600 Amphitheatre Pkwy",
    "addressLocality": ", Mountain View",
    "addressRegion": "CA",
    "postalCode": "94043",
    "addressCountry": "US"
    }
  },
 "baseSalary": {
    "@type": "MonetaryAmount",
    "currency": "USD",
    "value": {
      "@type": "QuantitativeValue",
      "value": 40.00,
      "unitText": "HOUR"
    }
  }
}

@Gummibeer
Copy link
Collaborator Author

Gummibeer commented Oct 10, 2019

Hey,

the documentation for identifier seems pretty bad. :/

I've used this snippet and got a valid preview. The identifier or @id aren't used for any displayed information. In ld+json @id is expected to contain a string and not an object. That's why the test tool throws an error.
The identifier/@id id only an ID, like the primary key in your database. It's common to use the URL, if available, to the entry. Because this is unique. But you also can use a simple ID from DB.

https://www.google.com/search?prvw=AHHjJUPmr5vPIAa4pU_dBRwdjzoqF_MCvA&q=previewid%3A0dbf9af4-1534-4917-ae0d-fd1ac9772be4&useragent=Mozilla%2F5.0+%28Linux%3B+Android+7.1.1%3B+Nexus+6+Build%2FN6F27M%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Chrome%2F66.0.3359.106+Mobile+Safari%2F537.36&filter=0&gws_rd=cr&newwindow=1&igu=1

<html>
<head>
<title>Software Engineer</title>
<script type="application/ld+json">
{
    "@context":"https://schema.org/",
    "@type":"JobPosting",
    "title":"PHP Open Source Developer",
    "description":"Open Source developers are needed everywhere and can help multiple ways.",
    "@id":"https://github.com/spatie/schema-org/php-open-source-developer",
    "datePosted":"2019-10-10",
    "validThrough":"2019-12-31T23:59",
    "employmentType":"VOLUNTEER",
    "hiringOrganization":{
        "@type":"Organization",
        "name":"Spatie",
        "sameAs":[
            "https://spatie.be",
            "https://github.com/spatie"
        ],
        "logo":"https://avatars0.githubusercontent.com/u/7535935?s=512&v=4"
    },
    "jobLocation":{
        "@type":"Place",
        "address":{
            "@type":"PostalAddress",
            "streetAddress":"Samberstraat 69/D",
            "addressLocality":"Antwerp",
            "addressRegion":"Antwerp",
            "postalCode":"2060",
            "addressCountry":"BE"
        }
    },
    "baseSalary":{
        "@type":"MonetaryAmount",
        "currency":"EUR",
        "value":{
            "@type":"QuantitativeValue",
            "value":0,
            "unitText":"YEAR"
        }
    }
}
</script>
</head>
<body>
</body>
</html>

@n0-m4d
Copy link

n0-m4d commented Oct 10, 2019

thanks for investigating.
shame on you, google. ;)

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

Successfully merging this pull request may close these issues.

Is there any way to add an @id to any schema property?
4 participants