Alex Rivera | Logout

Add new attribute (element) to JSON object using JavaScript

Asked 2009-04-10T03:00:22.820
584

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

Edit
Report

1 Answer

171

A JSON object is simply a javascript object, so with Javascript being a prototype based language, all you have to do is address it using the dot notation.

mything.NewField = 'foo';
answered 2009-04-10T03:04:59.827

Your Answer