Skip to content

Commit 2f3f7eb

Browse files
author
fangq
committed
partial fix of the NoRowBracket bug
git-svn-id: http://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab@458 786e58fb-9377-0410-9ff7-e4ac0ac0635c
1 parent e2eeb37 commit 2f3f7eb

File tree

2 files changed

+18
-14
lines changed

2 files changed

+18
-14
lines changed

examples/jsonlab_basictest.matlab

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -572,27 +572,27 @@ ans =
572572
"data2json": [
573573
[
574574
[
575-
[1],
575+
1,
576576
[
577-
[2],
578-
[3]
577+
2,
578+
3
579579
]
580580
],
581-
[7]
581+
7
582582
],
583583
[
584584
[
585-
[4],
586-
[5]
585+
4,
586+
5
587587
],
588588
[
589-
[8],
590-
[9]
589+
8,
590+
9
591591
]
592592
],
593593
[
594-
[6],
595-
[10]
594+
6,
595+
10
596596
]
597597
]
598598
}
@@ -601,7 +601,7 @@ ans =
601601
>>
602602
json2data =
603603

604-
data2json: [10x1 double]
604+
data2json: {{1x2 cell} [2x2 double] [6 10]}
605605

606606
>> >>
607607
%=================================================

savejson.m

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,14 +314,18 @@
314314
padding1,checkname(name,varargin{:}),nl,padding0,class(item),nl,padding0,regexprep(mat2str(size(item)),'\s+',','),nl);
315315
end
316316
else
317+
if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1 && level>0)
318+
numtxt=regexprep(regexprep(matdata2json(item,level+1,varargin{:}),'^\[',''),']','');
319+
else
320+
numtxt=matdata2json(item,level+1,varargin{:});
321+
end
317322
if(isempty(name))
318-
txt=sprintf('%s%s',padding1,matdata2json(item,level+1,varargin{:}));
323+
txt=sprintf('%s%s',padding1,numtxt);
319324
else
320325
if(numel(item)==1 && jsonopt('NoRowBracket',1,varargin{:})==1)
321-
numtxt=regexprep(regexprep(matdata2json(item,level+1,varargin{:}),'^\[',''),']','');
322326
txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt);
323327
else
324-
txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),matdata2json(item,level+1,varargin{:}));
328+
txt=sprintf('%s"%s": %s',padding1,checkname(name,varargin{:}),numtxt);
325329
end
326330
end
327331
return;

0 commit comments

Comments
 (0)