Skip to content
Snippets Groups Projects
Commit 3f6bfedb authored by fangq's avatar fangq
Browse files

making options case insensitive

git-svn-id: http://svn.code.sf.net/p/iso2mesh/code/trunk/jsonlab@484 786e58fb-9377-0410-9ff7-e4ac0ac0635c
parent e2a5b447
Branches
Tags
No related merge requests found
...@@ -26,7 +26,10 @@ function val=jsonopt(key,default,varargin) ...@@ -26,7 +26,10 @@ function val=jsonopt(key,default,varargin)
val=default; val=default;
if(nargin<=2) return; end if(nargin<=2) return; end
opt=varargin{1}; opt=varargin{1};
if(isstruct(opt) && isfield(opt,key)) if(isstruct(opt))
if(isfield(opt,key))
val=getfield(opt,key); val=getfield(opt,key);
elseif(isfield(opt,lower(key)))
val=getfield(opt,lower(key));
end
end end
...@@ -30,7 +30,7 @@ while(i<=len) ...@@ -30,7 +30,7 @@ while(i<=len)
if(isstruct(varargin{i})) if(isstruct(varargin{i}))
opt=mergestruct(opt,varargin{i}); opt=mergestruct(opt,varargin{i});
elseif(ischar(varargin{i}) && i<len) elseif(ischar(varargin{i}) && i<len)
opt=setfield(opt,varargin{i},varargin{i+1}); opt=setfield(opt,lower(varargin{i}),varargin{i+1});
i=i+1; i=i+1;
else else
error('input must be in the form of ...,''name'',value,... pairs or structs'); error('input must be in the form of ...,''name'',value,... pairs or structs');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment