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

JSONlab

JSONLab is a free and open-source JSON/UBJSON/MessagePack encoder and decoder written in the native MATLAB language. It can be used to convert a MATLAB data structure (array, struct, cell, struct array, cell array, and objects) into JSON/UBJSON/MessagePack formatted strings and files, or to parse a JSON/UBJSON/MessagePack file into MATLAB data structure. 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, widely used for data-exchange in applications. UBJSON (Universal Binary JSON) is a binary JSON format, specifically designed to specifically address the limitations of JSON, permitting efficient storage of binary data with strongly typed data records, resulting in smaller file sizes and fast encoding and decoding. MessagePack is another binary JSON-like data format widely used in data exchange in web/native applications. It is slightly more compact than UBJSON, but is not directly readable compared to UBJSON.

We envision that both JSON and its binary counterparts will play important rules not only for light-weight data storage, but also for storage and interchange of scientific data. It has both the flexibility and generality as in other general-purpose file specifications, such as HDF5 but has significantly reduced complexity and excellent readability.

Towards this goal, we have developed the JData Specification (http://github.com/fangq/jdata) to standardize serializations of complex scientific data structures, such as N-D arrays, sparse/complex-valued arrays, trees, maps, tables and graphs using JSON/binary JSON constructs. The text and binary formatted JData files are syntactically compatible with JSON/UBJSON formats, and can be readily parsed using existing JSON and UBJSON parsers. JSONLab is not just a parser and writer of JSON/UBJSON data files, but one that systematically converts complex scientific data structures into human-readable and universally supported JSON forms using the standardized JData data annotations.

JSONlab was developed by Qianqian Fang in the Dept. of Bioengineering at Northeastern University.

Why JSON?

  • 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

  • [2020/06/15]Nine years in the making,JSONLab 2.0 (Magnus Prime) has arrived! It provides a unified and systematic way to encode complex data and share among applications, thanks to the JData Specification. JSONLab's dependency, zmat toolbox, was also updated to 0.9.8.
  • [2019/10/24] We are excited to announce the arrival of JSONLab 2.0 beta (Magnus). This is perhaps the most significant release since the beginning of the project in 2011. JSONLab v2b supports MessagePack, lzma/lz4/lz4hc, more importantly, as the reference library for JData Specification.
  • [2017/01/02] Happy new year! JSONLab 1.5 is released. The new version contains a 2x speed acceleration for loadjson for large json files and an important bug fix to parse array of heterogeneous elements. From this version, the UBJSON floating point numbers (d/D) also use big-endian format (previously generated UBJSON files must be converted to use with the new version) Please see ChangeLog for details.
  • [2015/12/30] JSONLab 1.2 is released. The new version contains a 2x speed acceleration for savejson and a number of bug fixes. Please see ChangeLog for details. Thanks given to Mykhailo Bratukha, Insik Kim, Sertan Senturk and Oleg Komarov for their patches, suggestions and helpful discussions! Enjoy the new JSONlab and have a Happy New Year!
  • [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