javascript - Concatenating JSON Response Objects in Worklight Adapters -


i've written composite adapter makes multiple webservice calls , returns json object response stored in variables x & y respectively. supposed concatenate x , y since conform same json structure , return single object, "z" client application calls adapter. i'm getting error saying "cannot find function concat in object". have clue here ?

ex. var z = x.concat(y); return z;

json object doesn't have concat function. need iterate object fields , add them response. e.g. if have answ1, answ2 , answ3 might looks similar

function extendobj(dstobj, srcobj){     (var key in srcobj){           if(srcobj.hasownproperty(key)) dstobj[key] = srcobj[key];      } } 

after can use function concat objects

var response = {}; extendobj(response, answ1); extendobj(response, answ2); extendobj(response, answ3); return response; 

Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -