Showing revision 6.2

JSONlab: a toolbox to encode/decode JSON/UBJSON files in MATLAB/Octave


JSONlab is a free and open-source implementation of a JSON/UBJSON encoder and a decoder in the native MATLAB language. It can be used to convert a MATLAB data structure (array, struct, cell, struct array and cell array) into JSON/UBJSON formatted string, or decode a JSON/UBJSON file into MATLAB data. JSONlab supports both MATLAB and GNU Octave (a free MATLAB clone).

JSON (JavaScript Object Notation) is a highly portable, human-readable and "fat-free" text format to represent complex and hierarchical data. It is as powerful as XML, but less verbose. JSON format is widely used for data-exchange in applications, and is essential for the wild success of Ajax and Web2.0.

UBJSON (Universal Binary JSON) is a binary JSON format, specifically optimized for compact file size and better performance while keeping the semantics as simple as the text-based JSON format. Using the UBJSON format allows to wrap complex binary data in a flexible and extensible structure, making it possible to process complex and large dataset without accuracy loss due to text conversions.

We envision that both JSON and its binary version will serve as part of the mainstream data-exchange formats for scientific research in the future. It will provide the flexibility and generality achieved by other popular general-purpose file specifications, such as HDF5, with significantly reduced complexity and enhanced performance.

JSONlab was developed by Qianqian Fang at the Optics Division, Martinos Center for Biomedical Imaging, Massachusetts General Hospital/Harvard Medical School.

Learn Qianqian's other projects


  • JSON is a human-readable and self-explanatory plain-text format
  • JSON can represent arbitrarily complex datasets
  • JSON parsers for most programming languages are available for free
  • JSON data are web-friendly as it can be directly invoked (inline or load from remote site) in JavaScript

Share with the community Contribute to JSONlab Documentation and Release Notes Download JSONlab

What's New

  • [2015/06/05] JSONLab 1.1 is here, packed with lots of improvement, both bug fixes and speed enhancement. Thanks to those who shared suggestions or reported bugs. The new code is about 20x faster when loading a 150k-small-element JSON file, which is 30% faster than matlab 2015's webread function. Give it a try.
  • [2015/04/24] JSONLab is selected for MATLAB Central's "Pick of the Week". See this nice report from Jiro Doke. Its monthly download now exceeds 500 from MATLAB File Exchange site, with additional downloads from sourceforge.
  • [2015/01/02] Happy New Year! After 3 years of continuous development, here, I proudly announce the arrival of the JSONlab 1.0!. This represents a major milestone towards a fast, lightweight, and versatile JSON/UBJSON processing library in MATLAB/GNU Octave, and an exciting new start for implementing more advanced features and data formats (JMesh/JData). Please take a moment to review the updated documentation, ChangeLog and download your JSONlab 1.0 from here. As always, your feedback is critical. Please share it in our users' mailing list.
  • [2014/11/23] The second release candidate for JSONlab 1.0 has arrived!. This release contains morel bug fixes. It also has a few new features, such as compact JSON output, progress bar support when loading large JSON files etc. Checkout the ChangeLog and update your copy from here.
  • [2014/09/17] Here comes the first release candidate (RC1) of JSONLab 1.0. This release contains several critical bug fixes, including the reverse of integer Endianness of UBJSON data (thanks to Craig Pomeroy), escaping special characters in a JSON string (thanks to Ismail Badawi) and several compatibility issues running JSONLab on GNU Octave. JSONLab 1.0RC1 also includes the support for 2D cell-array and struct-array. !!!Important!!!: If you have previously generated UBJSON binary files on a little-endian system (Intel/AMD processors), please convert them using the new JSONLab to correct the Endianness. To do that, load the old binary data using data=loadubjson(filename,'IntEndian','L'); and then resave the data using saveubjson.
  • [2014/02/02] JSONlab 1.0 Beta is released! In this release, we fixed a few bugs related to saving and loading UBJSON. Please upgrade your jsonlab from this link.
  • [2013/08/23] JSONlab 1.0 Alpha is released! In this release, we added the long-waited Universal Binary JSON support to produce compact binary JSON files, which is potentially useful for many performance-sensitive applications. Please read the ChangeLog and download it from here.
  • [2012/12/18] JSONlab 0.9.1 is a stable release. Thanks to Niclas Borlin's fixes, jsonlab now has much better handling of empty and sparse matrices.
  • [2012/06/20] JSONlab 0.9.0 is here!. It has all the bug fixes and better loadjson-savejson round-trip consistency. Find details in ChangeLogs.
  • [2012/03/05] JSONlab 0.8.1 is ready for download. It features several bug fixes for proper handling of root-less objects and quotation marks. Read ChangeLogs for details.
  • [2012/01/13] JSONlab 0.8.0 (Sentinel) has arrived!. It contains major speed enhancements (20x) to loadjson for processing large data arrays, and several bug fixes. Please see ChangeLogs for more details. Get it from here.
  • [2011/10/21] JSONlab 0.5.1 (Nexus update 1) is available, fixing slow speed of loadjson and support JSON collection (a series of "{...}" enclosed JSON objects in a single file). See ChangeLogs.
  • [2011/10/16] First JSONlab release, 0.5 (Nexus), is ready for download.
  • [2011/10/10] First public announcement of the JSONlab project.
Powered by Habitat