microformats2-json: Difference between revisions

From Microformats Wiki
Jump to navigation Jump to search
(create stub page for zegnat)
 
(First draft of page structure.)
Line 1: Line 1:
{{stub}}
{{stub}}
<dfn style="font-style:normal;font-weight:bold">microformats2 JSON</dfn> is the canonical output format of the [[microformats2-parsing|microformats2 parsing]] algorithm. As such it can be used to compare parsers and create [[test-suite|test suites]]. It is also used as the official serialisation format of microformats objects, and relied upon by specifications such as [https://micropub.net/ Micropub].
<div style="margin:1em;padding:1em;background:#FFDC00">⚠️ The JSON format used is not pinned to a specific [https://indieweb.org/JSON#Specs JSON specification]. See [https://github.com/microformats/microformats2-parsing/issues/23 issue #23] for a discussion on the subject.</div>
== Parsed Document Format ==
Parsers collect not only microformats2 objects, but also [[rel|link relationships]]. Parsing an entire document will result in an outer object with 3 properties: <code>items</code>, <code>rels</code>, and <code>rel-urls</code>:
<pre>{
  "items": [],
  "rels": {},
  "rel-urls": {}
}</pre>
# <code>items</code> is an array of [[microformats2-json#microformat2_Objects|microformats2 objects]], ordered according to their order in the source document.
# <code>rels</code> is an object where the member names reflect all <code>rel</code>-values found in the source document.
# <code>rel-urls</code> is an object where the member names reflect all URLs found in the source document with <code>rel</code>-values attached.
== microformat2 Objects ==
<pre>{
  "type": [],
  "properties": {},
  "children": []
}</pre>
# <code>type</code> is an array of the types that identify the microformat, ordered alphabetically.
# <code>properties</code> is an object where the member names reflect all properties found for the microformat.
# The optional member <code>children</code> is an array of other microformats2 objects that were found nested in the current one.
=== type ===
=== properties ===
=== children ===
== rels Object ==
== rel-urls Object ==

Revision as of 19:37, 21 April 2018

This article is a stub. You can help the microformats.org wiki by expanding it.

microformats2 JSON is the canonical output format of the microformats2 parsing algorithm. As such it can be used to compare parsers and create test suites. It is also used as the official serialisation format of microformats objects, and relied upon by specifications such as Micropub.

⚠️ The JSON format used is not pinned to a specific JSON specification. See issue #23 for a discussion on the subject.

Parsed Document Format

Parsers collect not only microformats2 objects, but also link relationships. Parsing an entire document will result in an outer object with 3 properties: items, rels, and rel-urls:

{
  "items": [],
  "rels": {},
  "rel-urls": {}
}
  1. items is an array of microformats2 objects, ordered according to their order in the source document.
  2. rels is an object where the member names reflect all rel-values found in the source document.
  3. rel-urls is an object where the member names reflect all URLs found in the source document with rel-values attached.

microformat2 Objects

{ 
  "type": [],
  "properties": {},
  "children": []
}
  1. type is an array of the types that identify the microformat, ordered alphabetically.
  2. properties is an object where the member names reflect all properties found for the microformat.
  3. The optional member children is an array of other microformats2 objects that were found nested in the current one.

type

properties

children

rels Object

rel-urls Object