Luke SpringWalker Luke SpringWalker - 7 months ago 41
JSON Question

Javascript - Append a string to keys of an object including a dot character

I have the following

javacript object

Object {description: "This is a description."}

which I'm sending to the backend using the angular's
, but I need to append a string to the key before sending it using a

{bd.description: "This is a description."}

Is this possible?. So far I've been only able to create a
manually using the

It'd like to avoid creating a template of a
and filling it later, as the number of properties of the
is variable.


EDIT: it's not a nested object.


You could do something like this if you would like:

var myObject = { description: "this is stuff" } myObject['d.description'] = myObject.description delete myObject.description console.log(myObject) // { "d.description": "this is stuff" }