01 Nested catalogs (folders inside folders)

A JSON catalog has at most two levels: an optional list picker (lists), then the rows. Picking a row always downloads (or opens Details). Rows can't be folders, and one response has only one items array. So nesting in the JSON itself doesn't help.

For deeper trees, use the XML format, even for plain static files. Every folder is a small XML file whose folder entries link to the next file:

  <!-- library/index.xml -->
  <catalog>
    <entry><title>Fiction</title><info>3 books</info><link href="Fiction/index.xml"/><folder/></entry>
    <entry><title>Cosmos</title><info>Carl Sagan</info><file>Cosmos.epub</file><link href="Cosmos.epub"/></entry>
  </catalog>

  "browse": {
    "format": "xml",
    "url": "https://example.com/library/index.xml",
    "item": "entry", "container_element": "folder", "resolve_urls": true,
    "fields": { "title": "title", "author": "info", "id": "file", "url": "link@href" }
  },
  "download": { "url": "{url}", "filename": "{id}" }

With relative links, the whole tree can be uploaded to any static host unchanged. The nested-catalog example includes a script that writes one index.xml per folder of a local book tree.

- Depth
  JSON catalog: 2 (lists -> rows)
  XML catalog: unlimited
- Paging
  JSON catalog: yes
  XML catalog: no (200 entries per folder)
- Search, Details, version badges, bundles
  JSON catalog: yes
  XML catalog: no
- Order
  JSON catalog: as in the file
  XML catalog: folders first, then A-Z
Reader file (.txt)