JSON output schema
The document model that fetlar -t json prints, block by block.
fetlar FILE -t json prints the whole document as typed blocks. The same model is used for Word, Excel, PowerPoint, CSV, TSV and HTML.
{
"kind": "docx",
"pages": [
{
"page": 1,
"title": null,
"blocks": [
{ "type": "heading", "text": "4.2 Payment terms", "rtl": false, "level": 2, "page": 1 },
{ "type": "list_item", "text": "Approve the budget", "rtl": false, "level": 0, "ordered": true, "label": "1.", "page": 1 },
{ "type": "table", "text": "Item | Amount\nSalaries | 1,234,567.89", "rtl": false,
"rows": [["Item", "Amount"], ["Salaries", "1,234,567.89"]], "page": 1 }
]
}
]
}Top level
| Key | Meaning |
|---|---|
kind | the kind of file: docx, xlsx, pptx, csv, tsv or html. An old .xls has kind xlsx |
pages | a list of pages |
warnings | optional list of warnings, for example when a workbook was cut at the cell limit |
Pages
A page is the whole Word document, one visible Excel sheet, or one visible PowerPoint slide.
| Key | Meaning |
|---|---|
page | the page number, from 1 |
title | the slide title, or the sheet name where there is one. Otherwise null |
blocks | a list of blocks |
Blocks
Every block has type, text and rtl (true for right-to-left text).
type | Extra keys |
|---|---|
heading | level |
paragraph | |
list_item | level (nesting, from 0), ordered, label (the real number or bullet, such as 1. or (b)) |
table | rows: a list of rows, each a list of cell text |
chart | title, rows |
note | speaker notes |
footnote | |
header, footer | |
image | only with --images. The part name inside the file |
page on a block is the Word page it starts on, when the file records page breaks. A table's text is its rows joined with | and new lines. Number columns in a CSV table are marked for right alignment.
Compare output
fetlar diff -f json has its own shape: a kind and a list of changes, each with a kind (such as edited or cell_changed), a location and the old and new values. Edited Word paragraphs also carry spans, a list of equal, delete and insert pieces. See Comparing files for an example.