Rakesh Nair Rakesh Nair - 26 days ago 4
JSON Question

Add a new attribute to json object

I have a

object of the following format


I need to add a new attribute to each row based on some calculations.

Expected result


How can I achieve this using


Use Array.prototype.forEach method:

.forEach(obj => {
  obj.field4 = 'Something'

Sidenote on terminology: you don't have any JSON, you have javascript array (object). JSON is a string representation of this object, but in your question you are talking about object itself.