/

For the complete documentation index, see llms.txt. This page is also available as Markdown.

On this page

Data from JSON

The .json {path} docs ↗ function loads a JSON file and returns its content ready to use in your document.

The path parameter can be either a path relative to the main source file’s location or an absolute path. Use a slash (/) as the path separator, regardless of the operating system.

The shape of the returned value depends on the top-level JSON value:

Example 1

.code {json}
    .read {assets/config.json}

.json {assets/config.json}::get {database}::get {host}
{
  "name": "Quarkdown",
  "database": {
    "host": "localhost",
    "port": 5432
  },
  "features": ["math", "diagrams", "footnotes"]
}

localhost

Example 2

.code {json}
    .read {assets/people.json}

.json {assets/people.json}::foreach
    **.1::get {name}** is from .1::get {address}::get {country}
[
  {"name": "Alice", "address": {"country": "USA"}},
  {"name": "Bob", "address": {"country": "Italy"}},
  {"name": "Carol", "address": {"country": "Japan"}}
]

Alice is from USA

Bob is from Italy

Carol is from Japan