Docly Developers
Knowledge base Best practice Recommended

Give schemaless JSON files a .json extension

In shortA schemaless file written with saveJson or logJson should end in .json - state.json and log.json, not state and log. Docly stores the name exactly as given and adds no extension, so without it nothing in a file list tells a person or a script that the file is plain JSON rather than a document.
Applies to DataAPI
  1. What you'll see

    Code writes a small data file with docly.saveJson("#/Orders/123/state", data) or a log with docly.logJson("#/Orders/123/log", entry). The file gets exactly that name. In the Docly file list, in docly dir and in getFiles it sits next to the schema-bound documents with nothing to show that it is a schemaless JSON file.

  2. What's actually happening

    saveJson and logJson store the path you give them and add no extension. Schema-bound documents are .docly files, pages are .hash, code is .js — the extension is how people and scripts tell them apart. A schemaless JSON file without .json is the one file type that carries no such sign, so it gets mistaken for a document, opened in the wrong tool, or overlooked when a folder is cleaned up.

    Verified 2026-11-28: docly.saveJson("#/KBtest/state.json", { Count: 1 }) created a file listed as state.json with no schema, and docly.getJson("#/KBtest/state.json") read it back.

  3. What to do

    End every schemaless file name with .json, and read it by the same name:

    docly.saveJson("#/Orders/" + id + "/state.json", data);
    var s = docly.getJson("#/Orders/" + id + "/state.json") || {};
    docly.logJson("#/Orders/" + id + "/log.json", { Event: "Paid" });

    First ask whether the file should be schemaless at all. Records belong in schema-bound documents, where they get an editor form — see Keep private data under the # folder and Model a record as a document named by its key. Plain JSON is for what no one edits by hand: logs, caches and settings files such as #/site.json.

    Don't: docly.saveJson("#/Orders/123/state", data) — a file named state that looks like a document.

Last reviewed 28 Nov 2026