(upbeat music)
- [Instructor] I could generate my JSON-LD
for a person using a generator,
but I'm going to build it myself
just to take it step by step
what needs to be in the data, and how to put it together.
So I'm going to go ahead
and select Person in the JSON-LD playground.
And I get a starting point here.
I'm actually trying to create a person, so that's great.
And I've got my context and my type already set
because I am using the person type from schema.org.
So I'm going to do my snippet on Nelson Mandela.
And so I'm going to start by changing the name.
And I'm going to get to the job information a bit.
I know I'm not going to have a telephone number.
And I'm going to do the URL next.
So I'm going to move that up after the name.
I'm going to fix my indent.
And I've got to make sure to add a comment here,
and I have to take out the comma
after the job title.
And so for the URL,
let me me look at the Wikipedia page,
and I can just use this Wikipedia URL.
Good a place as any.
So I'll paste in that URL.
And then I'm going to look at schema.org at person.
There's a whole bunch of different pieces
of information I could provide here about a person.
I think birthplace is a really good common thing to include,
and we do have a BirthPlace property.
So over in the playground,
I'm gong to add BirthPlace.
And for the value, I will look over in Wikipedia.
We've got born and we got a description of the location.
So I'm just going to grab this text here.
And I'm going to put quotes in my snippet
and paste that in.
Take out that closing space.
And put a comma at the end.
Now, one of the other things
that's notable about Nelson Mandela in particular
is that he was the president of South Africa.
So I want to include an occupation.
And so looking through the person type,
we don't have an occupation option here.
But I've poked through this a little bit,
and there's a hasOccupation option,
and when I click that,
it tells me I can use Role as the property
to talk about past professions and dates.
So I'm going to go back to the page I was on
and look for Role.
It's not in person,
and I don't see it in thing.
But if I scroll down here to the bottom,
I don't see it there either.
So I'm going to do a search on this page for Role,
and there's the reference.
Use Role for expressing dates.
And then all of the other uses seem
to be just talking about the word role.
So let me do a broader search on schema.org.
And I'll do a search in the search box here.
See if I can find out about Role.
So here we go.
Role's another schema.org type.
So I'm going to open that up.
And so here I'm going to be creating
a sub-object it looks like.
Now, this is a situation where it might be useful
to use a generator to see how this is done
but let's try it out.
So back in the playground,
I'm going to go ahead and take out jobTitle,
and instead I'm going to put in hasOccupation,
which was the key that was suggested by the description,
and then for a role, this needs to be an object.
And so within a sub-object,
the first thing we need to do
is specify its schema.org type.
So I need an @Type, followed by Role.
And then I want to add properties and values for Role.
So looking over at Role,
the properties specific to Role
are roleName, startDate and endDate,
and that seems like a great set of data to include.
So let me go ahead and just put those properties in first.
roleName.
startDate.
And endDate.
All right, so then looking back in Wikipedia,
got president of South Africa.
So I'll go ahead and use that as the role name
in quotes, making sure I have that comma after that,
and then for the startDate, 10 May 1994.
End quotes.
And through 16 June 1999.
So I have basic information about Nelson Mandela,
and then I have information about one occupation,
which is a role and it has a roleName
and a start and an endDate.
I don't have any errors in the JSON-LD here.
So the JSON-LD I've created here is valid.
And again, I had to do a little bit of research
and poking around on schema.org
to understand what was possible
and how to actually insert this sub-object for hasOccupation
and how to use the Role type.
So again, in situations like these,
especially when you're working with a new type
of information, using a generator
or looking at examples and seeing how things fit together
can be really helpful.
So I'm going to take out this blank space here
that I don't need this empty line.
Then I'm going to copy all this content to the clipboard
and back in my files for this video,
I'm going to past this into the person.jsonld file,
and I'm going to save that.
And now I have a JSON-LD snippet about a person.