Skip to content

Commit

Permalink
jsonlab is compatible with matlab R2008
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed May 15, 2020
1 parent 86efe89 commit d88d454
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion examples/demo_jsonlab_basic.m
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
fprintf(1,'%% a container.Maps object \n')
fprintf(1,'%%=================================================\n\n')

data2json=containers.Map({'Andy','William','Om'},[21,21,22])
data2json=containers.Map({'Andy','William','Om'},{21,21,22})
savejson('',data2json)
json2data=loadjson(ans)
end
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_msgpack_basic.m
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@
fprintf(1,'%% a container.Maps object \n')
fprintf(1,'%%=================================================\n\n')

data2json=containers.Map({'Andy','William','Om'},[21,21,22])
data2json=containers.Map({'Andy','William','Om'},{21,21,22})
savemsgpack('',data2json)
json2data=loadmsgpack(ans)
end
Expand Down
2 changes: 1 addition & 1 deletion examples/demo_ubjson_basic.m
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@
fprintf(1,'%% a container.Maps object \n')
fprintf(1,'%%=================================================\n\n')

data2json=containers.Map({'Andy','William','Om'},[21,21,22])
data2json=containers.Map({'Andy','William','Om'},{21,21,22})
saveubjson('',data2json)
json2data=loadubjson(ans)
end
Expand Down
8 changes: 6 additions & 2 deletions jdataencode.m
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@
end
end
else % keep as a map and only encode its values
newitem=containers.Map('KeyType',item.KeyType,'ValueType','any');
if(strcmp(item.KeyType,'char'))
newitem=containers.Map();
else
newitem=containers.Map('KeyType',item.KeyType,'ValueType','any');
end
for i=1:length(names)
newitem(names{i})=obj2jd(item(names{i}),varargin{:});
end
Expand All @@ -153,7 +157,7 @@
function newitem=mat2jd(item,varargin)

if(isempty(item) || isa(item,'string') || ischar(item) || varargin{1}.nestarray || ...
((isvector(item) || ismatrix(item)) && isreal(item) && ~issparse(item)))
((isvector(item) || ndims(item)==2) && isreal(item) && ~issparse(item)))
newitem=item;
if(~(varargin{1}.messagepack && size(item,1)>1))
return;
Expand Down

0 comments on commit d88d454

Please sign in to comment.