javascript - Cannot get two objects united with Json.parse and Json.stringify -


i have doubt how unite objects , give them in express response in node js.

the object this:

{     "idp": 1,     "pasaportenum": 787643682,     "fidp": 1,     "fid_p": 1 } 

the other 1 also:

{     "idp": 1,     "pasaportenum": 827348,     "fidp": 1,     "fid_p": 75683475 } 

so code like:

var = json.stringify(context.instance[0].datavalues) var b = json.stringify(context.instance[2].datavalues)  res.send('{'+json.parse(a+','+b)+'}') 

why receive error?

 "unexpected token , in json @ position 53" 

at end need like:

{     "idp": 1,     "pasaportenum": 787643682,     "fidp": 1,     "fid_p": 1 }, {     "idp": 4,     "pasaportenum": 456789,     "fidp": 2,     "fid_p": 2 } 

regards

seeing have 2 objects same properties, want add array before stringifying

var arr = [context.instance[0].datavalues, context.instance[2].datavalues]  res.send( json.stringify( arr ) ) 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -