JSON LD là một cách để tạo schema
Differences between JSON-LD, Microdata, and RDFa¶
(in the context of HTML documents)
Microdata and RDFa are conceptually similar: both syntaxes define attributes that get added to your existing HTML elements.
JSON-LD is a syntax that gets added to a script
element (used as data block, not as script), separately from your existing markup.
So the primary difference between Microdata/RDFa and JSON-LD is that you have to repeat the content if using JSON-LD, while you can² mark up your existing content if using Microdata/RDFa.
These three snippets convey the same structured data (a Person
with a name
of “Alice”):
<!-- Microdata -->
<p itemscope itemtype="http://schema.org/Person">
Hi, I’m <span itemprop="name">Alice</span>.
</p>
<!-- RDFa -->
<p vocab="http://schema.org/" typeof="Person">
Hi, I’m <span property="name">Alice</span>.
</p>
<!-- JSON-LD -->
<p>
Hi, I’m Alice.
</p>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Person",
"name": "Alice"
}
</script>
Which to use?¶
JSON-LD if you want to add a blob of structured data, without having to care about existing markup. Might be easier for tools that don’t support structured data (and you use other tools to generate/add it), or when copy-pasting ready-made snippets.
Microdata/RDFa if you want to make use of your existing markup (so you don’t have to duplicate the content → DRY). Might be easier if adding it by hand, or when tools already support it (like Drupal).
If deciding between Microdata and RDFa: I recommend to use RDFa instead of Microdata, primarily because of the differences outlined in this answer on Stack Overflow.
RDFa and JSON-LD are both W3C Recommendations and both are RDF serializations.
Do I understand right, JSON-LD can only let you specify general info about whole page, but you can’t express which exactly parts of the webpage correspond to which object in JSON-LD? Like, if you have a list of books, you can specify in JSON-LD that this page shows a list of books, but you won’t be able to tell which of the books described in the JSON-LD correspond to which exactly element on the webpage? If so, Microdata/RDFa have one more important advantage: providing context to screenreaders used by blind people, but maybe I’m missing something in how JSON+LD works.
Nguồn:: Stack Overflow, How does Microdata rdfa compare to JSON-LD? - Software Engineering Stack Exchange
Open Graph chuyên cho việc chia sẻ trên mạng xã hội. Schema chuyên cho việc tìm kiếm trên Google