- List of NeuroJSON parsers/writers
Click on each library/utility on the left to read more.
-
python-jdata
Using the lightweight Python-JData module, a complex Python data structure can be encoded as a dict
object that is easily serialized as a JSON/binary JSON file and share such data between programs of different languages.
- URL
- https://pypi.org/project/jdata/
- Code
- https://github.com/NeuroJSON/pyjdata
- Install
-
For Debian Bullseye/Ubuntu 21.04 or newer
sudo apt-get install python3-jdata
For all other systems
pip install jdata
- Example
-
import jdata as jd
import numpy as np
a={'name':'jd','value':1,'array':np.arange(1,5,dtype=np.uint8)}
jd.show(a)
jd.save(a,'mydata.json') # jdata can dump numpy arrays to JSON
b=jd.load('mydata.json') # jdata loads both JSON and UBJSON
jd.save(b,'mydata.jdb') # save to UBJSON/Binary JData file
print(b)
-
python-bjdata - a lightweight binary JSON format for Python
This package was modified based on the py-ubjson package developed by Iotic Labs Ltd. The major changes were focused on supporting the Binary JData Specification Draft 1 - an extended Universal Binary JSON (UBJSON) Specification Draft-12.
- URL
- https://pypi.org/project/bjdata/
- Code
- https://github.com/NeuroJSON/pybj
- Install
-
For Debian Bullseye/Ubuntu 21.04 or newer
sudo apt-get install python3-bjdata
For all other systems
pip install bjdata
- Example
-
import bjdata as bj
a={'name':'jdata','value':1.0,'array':[1,2,4]}
bj.dumpb(a)
with open('data.jdb', 'w') as f:
bj.dump(data, f)
# alternatively, call jd.load/save
import jdata as jd
b=jd.load('data.jdb')
jd.save(b,'newdata.jdb')
-
JSONLab - a portable JSON/UBJSON/MsgPack reader/parser for MATLAB/Octave
JSONLab is one of the most popular JSON parsers for MATLAB, winning Popular Files 2018 and Editor's Pick.
- URL
- http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab
- Code
- https://github.com/NeuroJSON/jsonlab
- Install
-
For Debian Bullseye/Ubuntu 21.04 or newer
sudo apt-get install octave-jsonlab
For Fedora 24 or new
sudo dnf install octave-jsonlab
For all other systems
- https://github.com/NeuroJSON/jsonlab/releases
- Example
-
a=struct('name','jdata','value',1.0,'array',[1,2,4]);
savejson(a)
savejson('rootname',a)
savejson('rootname',a,'compact',1)
savejson('',a,'mydata.json')
savejson('ziparray',eye(10),'Compression','zlib','CompressArraySize',1)
savejson('',eye(10),'UseArrayShape',1)
dat=loadjson('{"obj":{"string":"value","array":[1,2,3]}}')
dat=loadjson('mydata.json')
savebj('rootname',a,'mydata.jdb') % save to bjdata binary JSON file
-
JNIfTY Toolbox - Fast and portable NIfTI-1/2 reader and NIfTI-to-JNIfTI converter
This is a fully functional NIfTI-1/2 reader/writer that supports both MATLAB and GNU Octave, and is capable of reading/writing both non-compressed and compressed NIfTI files (.nii, .nii.gz) as well as two-part Analyze7.5/NIfTI files (.hdr/.img and .hdr.gz/.img.gz). More importantly, this is a toolbox that converts NIfTI data to its JSON-based replacement, JNIfTI (.jnii for text-based and .bnii for binary-based), defined by the JNIfTI specification (https://github.com/NeuroJSON/jnifti). JNIfTI is a much more flexible, human-readable and extensible file format compared to the more rigid and opaque NIfTI format, making the data much easier to manipulate and share.
- URL
- https://github.com/NeuroJSON/jnifty
- Install
-
For Debian Bullseye/Ubuntu 21.04 or newer
sudo apt-get install octave-jnifti
For Fedora 24 or new
sudo dnf install octave-jnifti
For all other systems
- https://github.com/NeuroJSON/jnifty/releases
- Example
-
jnii=loadnifti('test.nii.gz'); % read a .nii.gz file as a jnii structure
jnii=loadnifti('test.nii', 'nii'); % read a .nii file as a nii structure
jnii=jnifticreate(uint8(magic(10)),'Name','10x10 magic matrix'); % create a JNIfTI structure
jnii=loadjnifti('test.jnii'); % read a .jnii file as a jnii structure
bnii=loadjnifti('test.bnii'); % read a binary .bnii file as a jnii structure
savejnifti(jnii, 'magic10.jnii');
savejnifti(jnii, 'magic10_zlib.bnii','Compression','zlib');
-
JSNIRF Toolbox - A portable MATLAB toolbox for parsing SNIRF (HDF5) and JSNIRF (JSON) files
This toolbox also provides a fast/complete reader/writer for the HDF5-based SNIRF files (along with any HDF5 data) via the EazyH5 toolbox (https://github.com/NeuroJSON/eazyh5). The toolbox can read/write SNIRF v1.0 data files specified by the SNIRF specification https://github.com/fNIRS/snirf .
- URL
- https://github.com/NeuroJSON/jsnirfy
- Install
-
- 1. To read/write SNIRF/HDF5 files, one must install the EazyH5 toolbox at https://github.com/NeuroJSON/eazyh5 ; this is only supported on MATLAB, not Octave.
- 2. To create/read/write JSNIRF files, one must install the JSONLab toolbox https://github.com/NeuroJSON/jsonlab ; this is supported on both MATLAB and Octave.
- 3. To read/write JSNIRF files with internal data compression, one must install the JSONLab toolbox https://github.com/NeuroJSON/jsonlab as well as ZMat toolbox https://github.com/fangq/zmat ; this is supported on both MATLAB and Octave.
- Example
-
data=loadsnirf('mydata.snirf'); % load an HDF5 SNIRF data file, same as loadh5+regrouph5
jdata=loadjsnirf('mydata.bnirs'); % load a binary JSON/JSNIRF data file
data=snirfcreate;
data.nirs.data.dataTimeSeries=rand(100,5);
data.nirs.metaDataTags.SubjectID='subj1';
data.nirs.metaDataTags.MeasurementDate=date;
savesnirf(data,'test.snirf');
savejsnirf(data,'test.jnirs');
-
jdata.js - JData encoder/decoder for JavaScript
jdata.js is an ultra-portable JavaScript module that can encode and decode NeuroJSON/JData data structure constructs in JavaScript/web and Node.js applications. It uses numjs as the backend when decoding N-D array JData constructs.
The NIH-funded MCX Cloud web-based Monte Carlo simulation utilizes JSData for decoding 3-D volumes written in the JNIfTI format by MCX and perform in-browser 3-D rendering using Three.js
- URL
- https://npmjs.com/package/jda
- Code
- https://github.com/NeuroJSON/jsdata
- Install
-
npm install jda
- Example
-
// import packages
var jdata = require('jda')
var nj = require('numjs')
global.atob = require("atob");
global.btoa = require("btoa");
// define sample data
let data={integer:1,shortarray:[1,2,3],object:[[[1],[2],[3]],null,false]};
// create jdata class with compression method "zlib"
let jd = new jdata(data,{compression:'zlib'});
console.log(jd.tojson()); //jdata can convert complex data to JSON
-
bjdata.js - JData encoder/decoder for JavaScript
BJData is a UBJSON-derived binary JSON format. bjdata.js
is a lightweight encoder and decoder for JavaScript and [Node.js].
- URL
- https://npmjs.com/package/bjd
- Code
- https://github.com/NeuroJSON/js-bjdata
- Install
-
npm install bjd
- Example
-
var bjd = require("bjd")
let data={integer:1,shortarray:[1,2,3],object:[[[1],[2],[3]],null,false]};
let buf = bjd.encode(data);
console.log(buf)
let newdata = bjd.decode(buf)[0];
console.log(newdata)
-
UBJ Binary JData (BJData) and UBJSON C parser
- URL
- https://github.com/NeuroJSON/ubj
-
JSON for Modern C++ JSON/UBJSON/MessagePack/CBOR/BJData parser
JSON for Modern C++ written by Niels Lohmann (@nlohmann) is one of the world's most widely used
C++ JSON and binary JSON parsers, accrued over 4 million downloads. In 2022, we have contributed
the extended capability to read/write BJData format developed by the NeuroJSON project. The BJData
support is included in release v3.11.0.
- URL
- https://github.com/nlohmann/json