JSONLab
Compact, portable, robust JSON/binary-JSON encoder/decoder for MATLAB/Octave
π What is JSONLab?
JSONLab is a comprehensive, open-source JSON/UBJSON/MessagePack encoder and decoder written entirely in native MATLAB language. It provides seamless conversion between MATLAB data structures and multiple serialization formats.
As the official reference implementation for both JData and BJData specifications, JSONLab enables unambiguous storage and exchange of complex scientific data structures across diverse programming environments.
π NeuroJSON Project
JSONLab is part of the NeuroJSON project (neurojson.org), funded by US NIH grant U24-NS124027. The project develops scalable, searchable, and reusable neuroimaging data formats using JSON/Binary JData as underlying serialization standards.
β‘ Core Capabilities
- Universal Compatibility: Works seamlessly across MATLAB R2008+ and GNU Octave 3.8+, ensuring broad accessibility
- Multi-Format Support: Native support for JSON, Binary JData, UBJSON, MessagePack, and HDF5 formats
- Complex Data Types: Full support for N-D arrays, sparse matrices, complex numbers, tables, and graphs
- Type Preservation: Maintains exact data types during serialization and deserialization
- Zero Dependencies: Written entirely in native MATLAB/Octave code with no external requirements
- Cross-Platform: Works identically on Windows, Linux, and macOS systems
π High-Performance Features
- Fast Array Parser: Highly optimized parser specifically designed for large N-D arrays, achieving up to 200% speed improvement over standard parsing
- Binary Formats: Binary JData and UBJSON provide significantly smaller file sizes (up to 50% reduction) and faster I/O operations
- Multi-Algorithm Compression: Support for zlib, gzip, lzma (highest compression), lz4 (fastest), lz4hc, and blosc2 meta-compressor
- Streaming Support: Process large datasets without loading entire files into memory
- Memory-Efficient: Optimized memory usage for handling large-scale scientific data
- JIT-Compatible: Code structure optimized for MATLAB's Just-In-Time compiler
πΎ Supported Data Formats
π Text-Based Formats
- JSON: Standard JSON with JData annotations
- .jdt: JData text files
- .jnii: JSON-based NIfTI neuroimaging format
- .jmsh: JSON mesh data
- .jnirs: JSON fNIRS data format
πΏ Binary Formats
- BJData: Binary JData (Draft 2)
- UBJSON: Universal Binary JSON
- MessagePack: Efficient binary serialization
- .pmat: Portable MATLAB session files
- HDF5: Hierarchical Data Format
π οΈ Advanced Tools & Features
πΊοΈ JSON Memory-Map (JSON-Mmap)
- Fast random access without full parsing
- Disk-map-like read/write operations
- JSONPath-based indexing
- Efficient for large files
π JSONPath Query Engine
- XPath-like data navigation
- Deep-scan operators (..)
- Array slicing and filtering
- Wildcard support
π Data Linking & Caching
- Dynamic external file loading via _DataLink_
- Automatic caching system
- On-demand data download
- Modular dataset management
π Cross-Platform Integration
- Python: pyjdata and pybj modules
- JavaScript: Standard JSON compatibility
- Built-in compression/decompression
- Base64 encoding utilities
![[Home]](upload/neurojson_banner_plain.png)