33= An open-source MATLAB/Octave JSON encoder and decoder =
44===============================================================================
55
6- *Copyright (C) 2011-2018 Qianqian Fang <q.fang at neu.edu>
6+ *Copyright (C) 2011-2019 Qianqian Fang <q.fang at neu.edu>
77*License: BSD or GNU General Public License version 3 (GPL v3), see License*.txt
8- *Version: 1.8 (Nominus )
8+ *Version: 1.9 (Magnus - alpha )
99
1010-------------------------------------------------------------------------------
1111
@@ -21,6 +21,13 @@ V. Contribution and feedback
2121
2222I. Introduction
2323
24+ JSONLab is a free and open-source implementation of a JSON/UBJSON encoder
25+ and a decoder in the native MATLAB language. It can be used to convert a MATLAB
26+ data structure (array, struct, cell, struct array and cell array) into
27+ JSON/UBJSON formatted strings, or to decode a JSON/UBJSON file into MATLAB
28+ data structure. JSONLab supports both MATLAB and
29+ [http://www.gnu.org/software/octave/ GNU Octave] (a free MATLAB clone).
30+
2431JSON ([http://www.json.org/ JavaScript Object Notation]) is a highly portable,
2532human-readable and "[http://en.wikipedia.org/wiki/JSON fat-free]" text format
2633to represent complex and hierarchical data. It is as powerful as
@@ -29,7 +36,7 @@ used for data-exchange in applications, and is essential for the wild success
2936of [http://en.wikipedia.org/wiki/Ajax_(programming) Ajax] and
3037[http://en.wikipedia.org/wiki/Web_2.0 Web2.0].
3138
32- UBJSON (Universal Binary JSON) is a binary JSON format, specifically
39+ UBJSON ([<http://ubjson.org/ Universal Binary JSON] ) is a binary JSON format, specifically
3340optimized for compact file size and better performance while keeping
3441the semantics as simple as the text-based JSON format. Using the UBJSON
3542format allows to wrap complex binary data in a flexible and extensible
@@ -43,13 +50,6 @@ general-purpose file specifications, such as
4350[http://www.hdfgroup.org/HDF5/whatishdf5.html HDF5], with significantly
4451reduced complexity and enhanced performance.
4552
46- JSONLab is a free and open-source implementation of a JSON/UBJSON encoder
47- and a decoder in the native MATLAB language. It can be used to convert a MATLAB
48- data structure (array, struct, cell, struct array and cell array) into
49- JSON/UBJSON formatted strings, or to decode a JSON/UBJSON file into MATLAB
50- data structure. JSONLab supports both MATLAB and
51- [http://www.gnu.org/software/octave/ GNU Octave] (a free MATLAB clone).
52-
5353-------------------------------------------------------------------------------
5454
5555II. Installation
@@ -62,10 +62,20 @@ by using the following command:
6262 addpath('/path/to/jsonlab');
6363
6464If you want to add this path permanently, you need to type "pathtool",
65- browse to the jsonlab root folder and add to the list, then click "Save".
66- Then, run "rehash" in MATLAB, and type "which loadjson ", if you see an
65+ browse to the zmat root folder and add to the list, then click "Save".
66+ Then, run "rehash" in MATLAB, and type "which savejson ", if you see an
6767output, that means JSONLab is installed for MATLAB/Octave.
6868
69+ If you use MATLAB in a shared environment such as a Linux server, the
70+ best way to add path is to type
71+
72+ mkdir ~/matlab/
73+ nano ~/matlab/startup.m
74+
75+ and type addpath('/path/to/jsonlab') in this file, save and quit the editor.
76+ MATLAB will execute this file every time it starts. For Octave, the file
77+ you need to edit is ~/.octaverc , where "~" is your home directory.
78+
6979-------------------------------------------------------------------------------
7080
7181III.Using JSONLab
@@ -122,6 +132,7 @@ JSON. The detailed help info for the four functions can be found below:
122132 array of 1D vectors; setting to 4 will return a
123133 3D cell array.
124134 opt.ShowProgress [0|1]: if set to 1, loadjson displays a progress bar.
135+ opt.ParseStringArray [0|1]: if set to 1, loadjson displays a progress bar.
125136
126137 output:
127138 dat: a cell array, where {...} blocks are converted into cell arrays,
@@ -134,7 +145,7 @@ JSON. The detailed help info for the four functions can be found below:
134145
135146 license:
136147 BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
137- </pre>
148+ </pre>
138149
139150=== savejson.m ===
140151
@@ -206,7 +217,22 @@ JSON. The detailed help info for the four functions can be found below:
206217 back to the string form
207218 opt.SaveBinary [0|1]: 1 - save the JSON file in binary mode; 0 - text mode.
208219 opt.Compact [0|1]: 1- out compact JSON format (remove all newlines and tabs)
209-
220+ opt.Compression 'zlib' or 'gzip': specify array compression
221+ method; currently only supports 'gzip' or 'zlib'. The
222+ data compression only applicable to numerical arrays
223+ in 3D or higher dimensions, or when ArrayToStruct
224+ is 1 for 1D or 2D arrays. If one wants to
225+ compress a long string, one must convert
226+ it to uint8 or int8 array first. The compressed
227+ array uses three extra fields
228+ "_ArrayCompressionMethod_": the opt.Compression value.
229+ "_ArrayCompressionSize_": a 1D interger array to
230+ store the pre-compressed (but post-processed)
231+ array dimensions, and
232+ "_ArrayCompressedData_": the "base64" encoded
233+ compressed binary array data.
234+ opt.CompressArraySize [100|int]: only to compress an array if the total
235+ element count is larger than this number.
210236 opt can be replaced by a list of ('param',value) pairs. The param
211237 string is equivallent to a field in opt and is case sensitive.
212238 output:
@@ -334,6 +360,23 @@ JSON. The detailed help info for the four functions can be found below:
334360 wrapped inside a function call as 'foo(...);'
335361 opt.UnpackHex [1|0]: conver the 0x[hex code] output by loadjson
336362 back to the string form
363+ opt.Compression 'zlib' or 'gzip': specify array compression
364+ method; currently only supports 'gzip' or 'zlib'. The
365+ data compression only applicable to numerical arrays
366+ in 3D or higher dimensions, or when ArrayToStruct
367+ is 1 for 1D or 2D arrays. If one wants to
368+ compress a long string, one must convert
369+ it to uint8 or int8 array first. The compressed
370+ array uses three extra fields
371+ "_ArrayCompressionMethod_": the opt.Compression value.
372+ "_ArrayCompressionSize_": a 1D interger array to
373+ store the pre-compressed (but post-processed)
374+ array dimensions, and
375+ "_ArrayCompressedData_": the binary stream of
376+ the compressed binary array data WITHOUT
377+ 'base64' encoding
378+ opt.CompressArraySize [100|int]: only to compress an array if the total
379+ element count is larger than this number.
337380
338381 opt can be replaced by a list of ('param',value) pairs. The param
339382 string is equivallent to a field in opt and is case sensitive.
@@ -399,33 +442,31 @@ that everyone else can enjoy the improvement. For anyone who want to contribute,
399442please download JSONLab source code from its source code repositories by using the
400443following command:
401444
402- git clone https://github.com/fangq/jsonlab.git jsonlab
445+ git clone https://github.com/fangq/jsonlab.git jsonlab
403446
404447or browsing the github site at
405448
406- https://github.com/fangq/jsonlab
407-
408- alternatively, if you prefer svn, you can checkout the latest code by using
409-
410- svn checkout svn://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab jsonlab
411-
412- You can make changes to the files as needed. Once you are satisfied with your
413- changes, and ready to share it with others, please cd the root directory of
414- JSONLab, and type
415-
416- git diff --no-prefix > yourname_featurename.patch
417-
418- or
449+ https://github.com/fangq/jsonlab
419450
420- svn diff > yourname_featurename.patch
451+ Sometimes, you may find it is necessary to modify JSONLab to achieve your
452+ goals, or attempt to modify JSONLab functions to fix a bug that you have
453+ encountered. If you are happy with your changes and willing to share those
454+ changes to the upstream author, you are recommended to create a pull-request
455+ on github.
421456
422- You then email the .patch file to JSONLab's maintainer, Qianqian Fang, at
423- the email address shown in the beginning of this file. Qianqian will review
424- the changes and commit it to the subversion if they are satisfactory.
457+ To create a pull-request, you first need to "fork" jsonlab on Github by
458+ clicking on the "fork" button on top-right of jsonlab's github page. Once you forked
459+ jsonlab to your own directory, you should then implement the changes in your
460+ own fork. After thoroughly testing it and you are confident the modification
461+ is complete and effective, you can then click on the "New pull request"
462+ button, and on the left, select fangq/jsonlab as the "base". Then type
463+ in the description of the changes. You are responsible to format the code
464+ updates using the same convention (tab-width: 8, indentation: 4 spaces) as
465+ the upstream code.
425466
426467We appreciate any suggestions and feedbacks from you. Please use the following
427468mailing list to report any questions you may have regarding JSONLab:
428469
429- https://groups.google.com/forum/?hl=en#!forum/jsonlab -users
470+ https://groups.google.com/forum/?hl=en#!forum/iso2mesh -users
430471
431472(Subscription to the mailing list is needed in order to post messages).
0 commit comments