Skip to content

Commit 2008934

Browse files
committed
[doc] additional documentations on decompression functions
1 parent 0a582fb commit 2008934

1 file changed

Lines changed: 19 additions & 9 deletions

File tree

README.rst

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ language-independent data annotation standard, all of which have been evolved
4242
from the over a decade development of JSONLab.
4343

4444
JSONLab v2.9.8 - code named "Micronus Prime - beta" - is the beta-release of the next milestone (v3.0),
45-
containing a number of key feature enhancement and bug fixes. The major
45+
containing a number of key feature enhancements and bug fixes. The major
4646
new features include
4747

48-
1. exporting JSON Memory-Map for rapid disk-map like JSON/binary JSON reading
48+
1. exporting JSON Memory-Map (``jsonget,jsonset``) for rapid disk-map like reading/writing of JSON/binary JSON files
4949
and writing, implementing `JSON-Mmap spec v1 Draft 1 <https://github.com/NeuroJSON/jsonmmap>`_
5050
2. supporting JSONPath query (``jsonpath``) to MATLAB data and JSON/binary JSON file and streams, including
5151
deep-scan operators,
@@ -57,8 +57,8 @@ new features include
5757
processing of complex JSON-encoded datasets such as neuroimaging datasets hosted on https://neurojson.io
5858
6. support high-performance Blosc2 meta-compressor for storing large N-D array data,
5959
7. ``savejson/loadjson`` can use MATLAB/Octave built-in ``jsonencode/jsondecode`` using the ``BuiltinJSON`` option
60-
8. automatically switch from struct to containers.Map when encoded key-length exceeds 63
61-
9. provide fall-back zlib/gzip compression/decompression function on Octave when ZMat is not installed
60+
8. automatically switch from ``struct`` to ``containers.Map`` when encoded key-length exceeds 63
61+
9. provide fall-back zlib/gzip compression/decompression function (``octavezmat``) on Octave when ZMat is not installed
6262

6363
There have been many major updates added to this release since the previous
6464
release v2.0 in June 2020. A list of the major changes are summarized below
@@ -834,7 +834,10 @@ Data Compression: {zlib,gzip,base64,lzma,lzip,lz4,lz4hc,zstd,blosc2}encode.m
834834
output = zlibencode(diag([1,2,3,4]))
835835
[output, info] = zlibencode(uint8(magic(8)))
836836
outputbase64 = char(base64encode(output(:)))
837+
838+
% char, numeric and logical ND-arrays are acceptable inputs to the compression functions
837839
[output, info] = gzipencode(uint8(magic(8)))
840+
838841
% setting a negative integer between -1 to -9 to set compression level: -9 being the highest
839842
[output, info] = zlibencode(uint8(magic(8)), -9)
840843
@@ -856,10 +859,18 @@ Data Deompression: {zlib,gzip,base64,lzma,lzip,lz4,lz4hc,zstd,blosc2}decode.m
856859

857860
.. code-block::
858861
862+
% passing on a compressed byte-array buffer to *decode function decompresses the buffer
859863
[compressed, info] = zlibencode(eye(10));
864+
865+
% the decompressed buffer is a byte-array
860866
decompressd = zlibdecode(compressed);
861-
decompressd = zlibdecode(compressed, info);
862867
868+
% to fully recover the original data structure, one most use the info struct returned by the compressor
869+
decompressd = zlibdecode(compressed, info)
870+
871+
% if one passes a zlib compressed buffer to a different decompressor, an error is reported
872+
decompressd = gzipdecode(compressed, info)
873+
outputbase64 = char(base64decode(base64encode('jsonlab test')))
863874
864875
========================================
865876
Using ``jsave/jload`` to share workspace
@@ -969,11 +980,10 @@ Once the necessary modules are installed, one can type ``python`` (or ``python3`
969980
970981
import jdata as jd
971982
import numpy as np
972-
from collections import OrderedDict
973983
974-
data1=jd.loadt('myfile.json',object_pairs_hook=OrderedDict);
975-
data2=jd.loadb('myfile.bjd',object_pairs_hook=OrderedDict);
976-
data3=jd.loadb('myfile.pmat',object_pairs_hook=OrderedDict);
984+
data1=jd.loadt('myfile.json');
985+
data2=jd.loadb('myfile.bjd');
986+
data3=jd.loadb('myfile.pmat');
977987
978988
where ``jd.loadt()`` function loads a text-based JSON file, performs
979989
JData decoding and converts the enclosed data into Python ``dict``, ``list``

0 commit comments

Comments
 (0)