JSONmmap
Memory-mapped file I/O for JSON and Binary JSON - dramatically accelerate reading and writing of large data files
📋 Synopsis
Format overview
⚡ Fast Access
Direct byte seeking
✏️ In-Place Updates
Modify without rewriting
📍 Storage Options
Inline or standalone
📋 JSON-Mmap Format Synopsis
[ ["path", [locator]], ["meta", value], ... ]
$ root$.key child$[0] array index
[start, len][start, len, ws₁][start, len, ws₁, ws₂]
Data: {"name": "Andy"}
Mmap: ["$.name", [10, 6, 1]]
⚡ Fast Random Access
Use byte offsets to seek directly to any data record without parsing the entire file.
// C example: read value at known position
FILE *fp = fopen("data.json", "rb");
fseek(fp, start - 1, SEEK_SET); // 1-indexed
fscanf(fp, "%d", &value);
fclose(fp);
// Python example
with open('data.json', 'rb') as f:
f.seek(start - 1)
chunk = f.read(length)
✏️ In-Place Updates
Modify values on disk using available whitespace without rewriting the entire file.
// Available space for new value:
max_bytes = length + ws_before + ws_after
// Write new value with padding
fseek(fp, start - ws_before - 1, SEEK_SET);
int len = snprintf(buf, max, "%d", newval);
// Pad remaining space with whitespace
memset(buf + len, ' ', max - len);
fwrite(buf, max, 1, fp);
🪶 Lightweight Format
JSON-Mmap uses the same format as your data - no additional parser needed.
// JSON-Mmap is just JSON arrays!
[
["MmapVersion", "0.5"],
["$", [1, 256]],
["$.data", [15, 200, 2]]
]
// Parse with any JSON library
mmap = JSON.parse(mmap_string);
[path, [start, len]] = mmap[1];
📍 Flexible Storage
Store mmap inline with data, embedded in metadata, or as a separate file.
// Inline direct (header + data)
[["$",[1,80]],...] {"actual":"data"}
// Standalone file pair
data.json ← your data
data.json.jmmap ← mmap table
// Embedded in metadata object
{"_info_": {"mmap": [["$",...]]}}
{"data": "..."}
JSON-Mmap defines a lightweight mapping table for fast disk-mapped file I/O. Read or update specific data records without parsing the entire file. Spec Version 0.5 (Draft 1)
![[Home]](upload/neurojson_banner_plain.png)