Skip to content

Commit 81feef3

Browse files
committed
skil no-op markers, update documentation
1 parent 4904155 commit 81feef3

8 files changed

Lines changed: 29 additions & 19 deletions

File tree

ChangeLog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ JSONlab ChangeLog (key features marked by *):
88

99
== JSONlab 2.0 (codename: Magnus Prime), FangQ <q.fang (at) neu.edu> ==
1010

11+
2020-06-09*[ ] created `jdata` and `bjdata` python modules to share data with MATLAB
1112
2020-06-08*[cbde607] add savebj and loadbj to dedicate to loading and saving bjdata
1213
2020-06-08*[e2451e1] add unit testing script, fix issues found in the testing unit
1314
2020-06-06 [a44015f] accelerate fast_match_bracket, drop unicode2native for speed

Contents.m

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
% jdatadecode - newdata=jdatadecode(data,opt,...)
1313
% jdataencode - jdata=jdataencode(data)
1414
% jsave - jsave(fname,'param1',value1,'param2',value2,...)
15-
% jload - jload(fname,'param1',value1,'param2',value2,...)
15+
% jload - vars=jload(fname,'param1',value1,'param2',value2,...)
1616
% jsonopt - val=jsonopt(key,default,optstruct)
1717
% loadbj - data=loadbj(fname,opt)
1818
% loadjson - data=loadjson(fname,opt)
@@ -726,21 +726,21 @@
726726
% to a field in opt. opt can have the following
727727
% fields (first in [.|.] is the default)
728728
%
729-
% ws ['base'|'wsname']: the name of the workspace in which the
729+
% ws ['caller'|'base']: the name of the workspace in which the
730730
% variables are to be saved
731731
% vars [{'var1','var2',...}]: cell array of variable names to be saved
732732
% matlab [0|1] if set to 1, use matlab's built-in jsonencode to
733733
% store encoded data to a json file; output file
734734
% must have a suffix of .jdt
735735
%
736-
% all options for saveubjson/savejson (depends on file suffix)
736+
% all options for savebj/savejson (depends on file suffix)
737737
% can be used to adjust the output unless "'matlab',1" is used
738738
%
739739
% output:
740740
% varlist: a list of variables loaded
741741
%
742742
% examples:
743-
% jsave % save all variables in the 'base' workspace to jamdata.jamm
743+
% jsave % save all variables in the 'caller' workspace to jamdata.jamm
744744
% jsave('mydat.jamm','vars', {'v1','v2',...}) % save selected variables
745745
% jsave('mydat.jamm','compression','lzma')
746746
%
@@ -753,6 +753,8 @@
753753
% jload
754754
% or
755755
% jload(fname)
756+
% varlist=jload(fname)
757+
% [varlist, header]=jload(fname)
756758
% varlist=jload(fname,'param1',value1,'param2',value2,...)
757759
%
758760
% Load variables from a JSON or binary JSON file to a workspace
@@ -769,7 +771,7 @@
769771
% to a field in opt. opt can have the following
770772
% fields (first in [.|.] is the default)
771773
%
772-
% ws ['base'|'wsname']: the name of the workspace in which the
774+
% ws ['caller'|'base']: the name of the workspace in which the
773775
% variables are to be saved
774776
% vars [{'var1','var2',...}]: list of variables to be saved
775777
% header [0|1]: if set to 1, return the metadata of the variables
@@ -782,13 +784,16 @@
782784
% can be used to adjust the parsing options
783785
%
784786
% output:
785-
% varlist: a list of variables loaded
787+
% varlist: a struct with each subfield a variable stored in the file,
788+
% if output is ignored, the variables will be loaded to the
789+
% workspace specified by the 'ws' option, which by default
790+
% load the variables to the current workspace ('caller')
786791
%
787792
% examples:
788-
% jload % load all variables in jamdata.jamm to the 'base' workspace
793+
% jload % load all variables in jamdata.jamm to the 'caller' workspace
789794
% jload mydat.jamm
790795
% jload('mydat.jamm','vars', {'v1','v2',...}) % load selected variables
791-
% jload('mydat.jamm','simplifycell',1)
796+
% varlist=jload('mydat.jamm','simplifycell',1)
792797
%
793798
% license:
794799
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
@@ -1425,5 +1430,3 @@
14251430
% license:
14261431
% BSD or GPL version 3, see LICENSE_{BSD,GPLv3}.txt files for details
14271432
%
1428-
1429-

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: jsonlab
22
Version: 2.0.0
3-
Date: 2020-06-01
3+
Date: 2020-06-13
44

55
Title: A JSON/UBJSON/MessagePack encoder/decoder for MATLAB/Octave
66
Author: Qianqian Fang <fangqq@gmail.com>

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,8 @@ jload.m
380380
.. code-block:: matlab
381381
382382
jload % load variables from jamdata.jamm to the current workspace
383-
jload mydata.jamm
384-
jload('mydata.jamm','vars',{'var1','var2'})
383+
jload mydata.jamm % load variables from mydata.jamm
384+
vars=jload('mydata.jamm','vars',{'var1','var2'}) % return vars.var1, vars.var2
385385
jload('mydata.jamm','simplifycell',0)
386386
jload('mydata.json')
387387

README.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ The main benefits of using .jamm file to share matlab variables include
334334
=== jload.m ===
335335

336336
jload % load variables from jamdata.jamm to the current workspace
337-
jload mydata.jamm
338-
jload('mydata.jamm','vars',{'var1','var2'})
337+
jload mydata.jamm % load variables from mydata.jamm
338+
vars=jload('mydata.jamm','vars',{'var1','var2'}) % return vars.var1, vars.var2
339339
jload('mydata.jamm','simplifycell',0)
340340
jload('mydata.json')
341341

loadbj.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@
244244
c = [];
245245
else
246246
c = inputstr(pos);
247+
while(c=='N')
248+
pos=pos+1;
249+
c = inputstr(pos);
250+
end
247251
end
248252
end
249253

@@ -307,7 +311,8 @@
307311
%%-------------------------------------------------------------------------
308312

309313
function [val, pos] = parse_value(inputstr, pos, varargin)
310-
switch(inputstr(pos))
314+
[cc,pos]=next_char(inputstr,pos);
315+
switch(cc)
311316
case {'S','C','H'}
312317
[val, pos] = parseStr(inputstr, pos, varargin{:});
313318
return;

saveubjson.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@
6363
%
6464

6565
if(nargin==1)
66-
ubj=saveubjson('',rootname,'ubjson',1);
66+
ubj=savebj('',rootname,'ubjson',1);
6767
elseif(length(varargin)==1 && ischar(varargin{1}))
68-
ubj=saveubjson(rootname,obj,'FileName',varargin{1},'ubjson',1);
68+
ubj=savebj(rootname,obj,'FileName',varargin{1},'ubjson',1);
6969
else
70-
ubj=saveubjson(rootname,obj,varargin{:},'ubjson',1);
70+
ubj=savebj(rootname,obj,varargin{:},'ubjson',1);
7171
end

test/run_jsonlab_test.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ function run_jsonlab_test(tests)
171171
test_jsonlab('empty array',@savebj,[],'Z','debug',1);
172172
test_jsonlab('empty cell',@savebj,{},'Z','debug',1);
173173
test_jsonlab('empty string',@savebj,'','SU<0>','debug',1);
174+
test_jsonlab('skip no-op before marker and after value',@savebj,loadbj(char(['NN[NU' char(5) 'NNNU' char(1) ']'])),'[$U#U<2><5><1>','debug',1);
174175
test_jsonlab('string escape',@savebj,sprintf('jdata\n\b\ashall\tprevail\t"\"\\'),sprintf('SU<25>jdata\n\b\ashall\tprevail\t\"\"\\'),'debug',1);
175176
if(exist('isstring'))
176177
test_jsonlab('string type',@savebj,string(sprintf('jdata\n\b\ashall\tprevail')),sprintf('[SU<21>jdata\n\b\ashall\tprevail]'),'debug',1);

0 commit comments

Comments
 (0)