使用JavaScript将新属性(元素)添加到JSON对象 [英] Add new attribute (element) to JSON object using JavaScript

查看:149
本文介绍了使用JavaScript将新属性(元素)添加到JSON对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用JavaScript将新属性(元素)添加到JSON对象?

How do I add new attribute (element) to JSON object using JavaScript?

推荐答案

JSON代表JavaScript Object Notation。 JSON对象实际上是一个尚未转换为它所代表的对象的字符串。

JSON stands for JavaScript Object Notation. A JSON object is really a string that has yet to be turned into the object it represents.

要在JS中为现有对象添加属性,您可以执行以下操作。

To add a property to an existing object in JS you could do the following.

object["property"] = value;

object.property = value;

如果你提供一些额外的信息,比如你在上下文中需要做什么,你可能会得到一个更加量身定制的回答。

If you provide some extra info like exactly what you need to do in context you might get a more tailored answer.

这篇关于使用JavaScript将新属性(元素)添加到JSON对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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