From 39a43bf347379f3b9e595a933f09bf174af9ac9f Mon Sep 17 00:00:00 2001 From: mobeets Date: Tue, 24 Jan 2017 11:22:09 -0500 Subject: [PATCH] loadjson fix --- loadjson_internal.m | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/loadjson_internal.m b/loadjson_internal.m index c28ab47..80c4429 100644 --- a/loadjson_internal.m +++ b/loadjson_internal.m @@ -676,6 +676,41 @@ function error_pos(msg, inStr) end i=i+1; end +%%------------------------------------------------------------------------- +function s=mergestruct(s1,s2) +% +% s=mergestruct(s1,s2) +% +% merge two struct objects into one +% +% authors:Qianqian Fang (q.fang neu.edu) +% date: 2012/12/22 +% +% input: +% s1,s2: a struct object, s1 and s2 can not be arrays +% +% output: +% s: the merged struct object. fields in s1 and s2 will be combined in s. +% +% license: +% BSD License, see LICENSE_BSD.txt files for details +% +% -- this function is part of jsonlab toolbox (http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab) +% + +if(~isstruct(s1) || ~isstruct(s2)) + error('input parameters contain non-struct'); +end +if(length(s1)>1 || length(s2)>1) + error('can not merge struct arrays'); +end +fn=fieldnames(s2); +s=s1; +for i=1:length(fn) + s=setfield(s,fn{i},getfield(s2,fn{i})); +end + + %%------------------------------------------------------------------------- % license.txt %%-------------------------------------------------------------------------