向node.js中的现有json对象添加新属性

向node.js中的现有json对象添加新属性

问题描述:

我有一个这样的物体

==================records=========={ Id: 5114a3c21203e0d811000088,
  userId: 'test',
  sUserId: test,
  userName: 'test',
  url: 'test',
  Title: 'test'
}

我需要在上述记录中添加一个新字段 Name:'test',我尝试提供记录.Name= name,它无效.

I need to add a new field Name : 'test' to the above record, I tried giving records.Name = name, it didn't work.

请帮助

谢谢, 美味

发现此问题的OP在原始问题下方的评论中提到该问题的解决方案是:

Those finding this problem, OP mentioned in a comment below the original question that the solution for this problem is:

records.set('Name', 'test')

这将添加一个名为Name的新属性,其值为test.

This adds a new attribute called Name having value test.