JSONLab: a toolbox to encode/decode JSON files
Editor's Note: Popular File 2018
This file was selected as MATLAB Central Pick of the Week
** JSONLab 2.0 Final (Magnus Prime) is released on 06/14/2020.**
==============================================================
Release URL: https://github.com/fangq/jsonlab/releases/tag/v2.0
Depends on: https://www.mathworks.com/matlabcentral/fileexchange/71434-zmat
Data format according to
- JData Specification Draft-3: http://github.com/OpenJData/jdata, and
- Binary JData Specification Draft-1: http://github.com/OpenJData/bjdata
Python modules to read/write JSONLab files:
- jdata: https://pypi.org/project/jdata/
- bjdata: https://pypi.org/project/bjdata/
==============================================================
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 [http://www.gnu.org/software/octave] (a free MATLAB clone).
JSON (JavaScript Object Notation, http://www.json.org/) 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,
http://ubjson.org/ ) is a binary JSON format, 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 [http://www.hdfgroup.org/HDF5/whatishdf5.html]
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.
Please find detailed online help at http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab/Doc
== What's New ==
JSONLab v2.0 - code named "Magnus Prime" - is a stable release of JSONLab and
a new milestone towards a stable, complete reference implementation of the
JData Specification (http://openjdata.org) for portable scientific data storage.
There have been many major updates added to this release since the previous
release v1.9.8 in Oct. 2019. A list of the major changes are summarized below
(with key features marked by *), including the support to `_ArrayShape_` to
efficiently encode special matrices and the addition of `jsave/jload` to save
and restore variables in MATLAB/Octave like the `save/load` commands (experimental).
=== jsave.m ===
jsave % save the current workspace to jamdata.jamm
jsave mydata.jamm
jsave('mydata.jamm','vars',{'var1','var2'})
jsave('mydata.jamm','compression','lzma')
=== jload.m ===
jload % load variables from jamdata.jamm to the current workspace
jload mydata.jamm % load variables
vars=jload('mydata.jamm','vars',{'var1','var2'})
== Other updates
*change default workspace to caller for jload and jsave
*created `jdata` and `bjdata` python modules to share data with MATLAB
*add savebj and loadbj to dedicate to loading and saving bjdata
*add unit testing script, fix issues found in the testing unit
*accelerate fast_match_bracket, drop unicode2native for speed
*support Toeplitz matrices, use case-insensitive comparison
*jdatadecode now handles _ArrayOrder_
*add keeptype option to jsave and saveubjson
*make jsave and jload work on octave
*apply data compression to strings, new datatype char
*fix loadmsgpack ND array issue
*add jsave and jload for portable data sharing
*adding support to _ArrayShape_ to record special matrices
*jsonlab is compatible with matlab R2008
*saveubjson now implments BJData spec Draft1,https://github.com/fangq/bjdata
*add UseMap option to avoid key name conversion
*reduce jsonopt calls to speed up encoding and decoding
*enable jdataencode in savejson and saveubjson
Cite As
Qianqian Fang (2023). JSONLab: a toolbox to encode/decode JSON files (https://www.mathworks.com/matlabcentral/fileexchange/33381-jsonlab-a-toolbox-to-encode-decode-json-files), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
- MATLAB > Data Import and Analysis > Data Import and Export > Web Access and Streaming > Web Services >
- MATLAB > External Language Interfaces > Other languages > Octave >
- MATLAB > Data Import and Analysis > Data Import and Export > Standard File Formats > HDF5 >
- MATLAB > Data Import and Analysis > Data Import and Export > Standard File Formats > JSON Format >
Tags
Acknowledgements
Inspired by: zmat, Byte encoding utilities, (another) JSON Parser, JSON Parser, Highly portable JSON-input parser
Inspired: googleMapAPIを利用した走行ルートデータ作成, Matlab to Google Sheets (matlab2sheets), QuinnSys/QuinnSys-OAPI, Light Field Toolbox v0.4 -- deprecated, v0.5 available now, LOL Chuck, SlackMatlab, JCDstatusPlot, Core_jsonparser: Import and Export JSON files using MATLAB, sonyalpha: Control a Sony Alpha Camera, JSONRPC2: a set of classes to encode/decode JSON RPC messages, deprecated -- Light Field Toolbox v0.2 -- v0.3 now available, deprecated -- Light Field Toolbox v0.3 -- v0.4 now available, Beam information
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
jsonlab-2.0
jsonlab-2.0/examples
jsonlab-2.0/test
Version | Published | Release Notes | |
---|---|---|---|
2.0.1 | - fix bjdata spec link |
||
2.0 | - add unit testing script
|
||
1.15.0.0 | ChangeLog:
|
|
|
1.13.0.0 | ChangeLog:
|
||
1.12.0.0 | - update to jsonlab 1.0 beta release
|
||
1.11.0.0 | update to 1.0 alpha release, included functions (saveubjson and loadubjson) for writing and reading Universal Binary JSON files |
||
1.10.0.0 | ChangeLog - 2012/06/17 *new format for an invalid leading char, unpacking hex code in savejson
|
||
1.9.8.4 | - fix a bug in saveubjson when saving integer 256 |
||
1.9.8.3 | - fix openjdata.org link |
||
1.9.8.2 | - update savejson and saveubjson license statement |
||
1.9.8.1 | -Avoid double expanding arrayzipdata in savejson and saveubjson |
|
|
1.9.8 | -Official reference implementation for JData Spec Draft 2(http://github.com/fangq/jdata)
|
|
|
1.9 | ChangeLog: 2012/02/28 loadjson quotation mark escape bug, see http://bit.ly/yyk1nS
|
|
|
1.7.0.0 | ChangeLog:
|
||
1.5 | -use Big-endian format to store floating points (d/D) in saveubjson
|
|
|
1.3.0.0 | ChangeLog: 2011/10/21 fix a bug in loadjson, previous code does not use any of the acceleration
|
||
1.2.0.0 | - 2x speed in savejson (Issue#17)
|
||
1.1.0.0 | -massively accelerating loadjson
|