How to map new property values to an array of JSON objects? -


i'm reading record sets in express server using node mssql package. reading values outputs array of json objects expected.

now need modify email propoerty value of each json object. tried looping through recordset , changing value @ each index:

            var request = new sql.request(sql.globalconnection);             request.input('p_email', sql.varchar(50), useremail);             request.execute('getddmuserprofile', function(err, recordsets, returnvalue) {                       (var = 0; < recordsets.length; i++){                     recordsets[i].email = "joe@gmail.com";                  }                  console.log(recordsets);              }); 

but instead of modifying emailvalue of each json object, code appends new email property last json object.

how can map new property values array of json objects?

example output: example of output shown below, new email property has been added end of array instead of changing each existing property value:

[      [         {            id:[               4          ],          username:"brian",          email:"joe@gmail.com"       },       {            id:[               5          ],          username:"brian",          email:"joe@gmail.com"       }          email:'joe@gmail.com' ] ] 

the issue here dataset appears not array of json objects but, rather, array of arrays of json objects. if know you'll have 1 array in top-most array, can solve problem this:

recordsets[0][i].email = "joe@gmail.com"; 

to target first array in top-most array. however, if top-most array potentially have more 1 array, that'll different kind of issue solve.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -