向node.js中的现有json对象添加新属性 [英] Add a new attribute to existing json object in node.js

查看:309
本文介绍了向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.

这篇关于向node.js中的现有json对象添加新属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆