Reputation: 15230
I have a JavaScript object like:
appointerment= {ids: '15,16,17', appointments: {'15': '12.05.2010,14,05,2010'} }
now in appointments object I want to add something like '16': '21.05.2010'
what is the best possible way to do this?
Upvotes: 1
Views: 6196
Reputation: 130750
var x = { a:1, b:{c:1} }
x.b.d = 1
// x is now { a:1, b:{c:1, d:1} }
Note - But this won't work in the case of numbers like '16'.
Upvotes: 0
Reputation: 527478
appointerment.appointments['16'] = '21.05.2010';
JSON is short for "JavaScript Object Notation", and as the name implies, it's basically just a way of representing Javascript objects. Thus, one can interact with JSON in the ways one tends to interact with any other object in Javascript, via the usage of the .
or []
operators.
Upvotes: 6